package com.shsh.safemanage.action;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import com.shsh.safemanage.dao.AccidentDao;
import com.shsh.safemanage.dao.DaoCreator;
import com.shsh.safemanage.dao.DepartmentDao;
import com.shsh.safemanage.dao.EquipmentDao;
import com.shsh.safemanage.dao.HSEProblemDao;
import com.shsh.safemanage.dao.ProblemDao;
import com.shsh.safemanage.dao.RoleDao;
import com.shsh.safemanage.dao.TitlePostManageGroupDao;
import com.shsh.safemanage.dao.UserDao;
import com.shsh.safemanage.model.AccidentCasualty;
import com.shsh.safemanage.model.AccidentCheckForm;
import com.shsh.safemanage.model.AccidentInfoSheet;
import com.shsh.safemanage.model.AccidentRegisterForm;
import com.shsh.safemanage.model.AccidentReport;
import com.shsh.safemanage.model.Defect;
import com.shsh.safemanage.model.Department1;
import com.shsh.safemanage.model.Department2;
import com.shsh.safemanage.model.Department3;
import com.shsh.safemanage.model.Equipment;
import com.shsh.safemanage.model.HSECategory;
import com.shsh.safemanage.model.JobPost;
import com.shsh.safemanage.model.ManageGroup;
import com.shsh.safemanage.model.Other;
import com.shsh.safemanage.model.Problem;
import com.shsh.safemanage.model.ProblemHSECategory;
import com.shsh.safemanage.model.ProblemTransfer;
import com.shsh.safemanage.model.Role;
import com.shsh.safemanage.model.Shutdown;
import com.shsh.safemanage.model.Tendency;
import com.shsh.safemanage.model.User;
import com.shsh.safemanage.util.Constants;
import com.shsh.safemanage.util.MessageUtil;
import com.shsh.safemanage.util.RequestUtil;
import com.shsh.safemanage.util.Util;
import com.shsh.safemanage.util.ValueUtil;

public class WriteProblemAction {
	public boolean chooseManageGroupUser(HttpServletRequest request) {
		String userIDsStr = request.getParameter(Constants.REQUEST_PARAMETER_ID);
		String manageGroupIDStr = request.getParameter(Constants.REQUEST_PARAMETER_MANAGEGROUP_ID);

		if (Util.isNullOrEmpty(userIDsStr) || Util.isNullOrEmpty(manageGroupIDStr)) {
			return true;
		}

		HttpSession session = request.getSession();

		String[] userIDArr = userIDsStr.split(",");
		Long manageGroupID = 0L;
		try {
			Map<Long, Set<Long>> map = (Map<Long, Set<Long>>) session.getAttribute(Constants.SESSION_MANAGE_GROUP_USER);
			if (map == null) {
				map = new HashMap<Long, Set<Long>>();
				session.setAttribute(Constants.SESSION_MANAGE_GROUP_USER, map);
			}

			manageGroupID = new Long(manageGroupIDStr);
			Set<Long> set = map.get(manageGroupID);
			if (set == null) {
				set = new HashSet<Long>();
				map.put(manageGroupID, set);
			}
			set.clear();

			for (String userIDStr : userIDArr) {
				Long userID = new Long(userIDStr);
				set.add(userID);
			}

			return true;
		} catch (Exception e) {
		}

		return false;
	}

	public boolean chooseProblemDepartment1(HttpServletRequest request) {
		HttpSession session = request.getSession();

		String idStr = request.getParameter(Constants.REQUEST_PARAMETER_ID);
		try {
			Long id = new Long(idStr);
			DepartmentDao departmentDao = DaoCreator.createDepartmentDao();
			Department1 department1 = departmentDao.getDepartment1ByID(id);

			session.setAttribute(Constants.SESSION_PROBLEM_DEPARTMENT1, department1);

			return true;
		} catch (Exception e) {
			return false;
		}
	}

	public boolean chooseProblemDepartment1List(HttpServletRequest request) {
		HttpSession session = request.getSession();

		String idStrs = request.getParameter(Constants.REQUEST_PARAMETER_ID);
		try {
			String[] idStrList = idStrs.split(",");
			List<Department1> depart1List = new ArrayList<Department1>();
			DepartmentDao departmentDao = DaoCreator.createDepartmentDao();
			for (String idStr : idStrList) {
				Long id = new Long(idStr);
				Department1 department1 = departmentDao.getDepartment1ByID(id);

				depart1List.add(department1);
			}

			session.setAttribute(Constants.SESSION_PROBLEM_DEPARTMENT1, depart1List);

			return true;
		} catch (Exception e) {
			return false;
		}
	}

	public boolean chooseDepartment2(HttpServletRequest request) {
		HttpSession session = request.getSession();

		String idStr = request.getParameter(Constants.REQUEST_PARAMETER_ID);
		try {
			Long id = new Long(idStr);
			DepartmentDao departmentDao = DaoCreator.createDepartmentDao();
			Department2 department2 = departmentDao.getDepartment2ByID(id);

			session.setAttribute(Constants.SESSION_DEPARTMENT2, department2);

			return true;
		} catch (Exception e) {
			return false;
		}
	}

	public String getSessionDepartment2Str(HttpSession session) {
		Department2 depart2 = (Department2) session.getAttribute(Constants.SESSION_DEPARTMENT2);
		if (depart2 != null) {
			return depart2.getDepartment2Name();
		}

		return "";
	}

	public boolean chooseProblemEquipment(HttpServletRequest request) {
		HttpSession session = request.getSession();

		String idStr = request.getParameter(Constants.REQUEST_PARAMETER_ID);
		try {
			Long id = new Long(idStr);
			EquipmentDao equipmentDao = DaoCreator.createEquipmentDao();
			Equipment equipment = equipmentDao.getEquipment(id);

			session.setAttribute(Constants.SESSION_PROBLEM_EQUIPMENT, equipment);

			return true;
		} catch (Exception e) {
			return false;
		}
	}

	public boolean writeProblem(HttpServletRequest request) {
		String problemTitle = request.getParameter(Constants.REQUEST_PARAMETER_PROBLEM_TITLE);
		String problemContent = request.getParameter(Constants.REQUEST_PARAMETER_PROBLEM_CONTENT);
		String problemZhenggai = request.getParameter(Constants.REQUEST_PARAMETER_ZHENGGAI_CUOSHI);
		String problemDepart1IDStr = request.getParameter(Constants.REQUEST_PARAMETER_DEPARTMENT1ID);
		String problemEquipIDStr = request.getParameter(Constants.REQUEST_PARAMETER_EQUIP_ID);
		String problemManageGroupUserIDStr = request.getParameter(Constants.REQUEST_PARAMETER_USER_ID);
		String isSolvedStr = request.getParameter(Constants.REQUEST_PARAMETER_IS_SOLVED);
		String categoryPerPosIDStr = request.getParameter(Constants.REQUEST_PARAMETER_CATEGORY_PERSON_POSITION_ID);
		String categoryPerEquipIDStr = request.getParameter(Constants.REQUEST_PARAMETER_CATEGORY_PERSON_EQUIP_ID);
		String categoryWorkActIDStr = request.getParameter(Constants.REQUEST_PARAMETER_CATEGORY_WORK_ACTIVITY_ID);
		String categoryToolEquipIDStr = request.getParameter(Constants.REQUEST_PARAMETER_CATEGORY_TOOL_EQUIP_ID);
		String categoryWorkEnvIDStr = request.getParameter(Constants.REQUEST_PARAMETER_CATEGORY_WORK_ENVIRONMENT_ID);
		String categoryPerPosOther = request.getParameter(Constants.REQUEST_PARAMETER_CATEGORY_PERSON_POSITION_OTHER);
		String categoryPerEquipOther = request.getParameter(Constants.REQUEST_PARAMETER_CATEGORY_PERSON_EQUIP_OTHER);
		String categoryWorkActOther = request.getParameter(Constants.REQUEST_PARAMETER_CATEGORY_WORK_ACTIVITY_OTHER);
		String categoryToolEquipOther = request.getParameter(Constants.REQUEST_PARAMETER_CATEGORY_TOOL_EQUIP_OTHER);
		String categoryWorkEnvOther = request.getParameter(Constants.REQUEST_PARAMETER_CATEGORY_WORK_ENVIRONMENT_OTHER);

		HttpSession session = request.getSession();
		User user = (User) session.getAttribute(Constants.SESSION_USER);

		EquipmentDao equipmentDao = DaoCreator.createEquipmentDao();
		DepartmentDao departmentDao = DaoCreator.createDepartmentDao();
		HSEProblemDao hseProblemDao = DaoCreator.createHSEProblemDao();

		UserAction userAction = ActionCreator.createUserAction();

		Long problemDepart1ID = 0L;
		try {
			problemDepart1ID = new Long(problemDepart1IDStr);
		} catch (Exception e) {
			problemDepart1ID = user.getDepartment1ID();
		}

		Department2 userDepart2 = departmentDao.getDepartment2ByID(user.getDepartment2ID());
		Long problemEquipID = 0L;
		try {
			problemEquipID = new Long(problemEquipIDStr);
		} catch (Exception e) {
			if (userDepart2.isEquip()) {
				problemEquipID = userDepart2.getEquipID();
			}
		}

		List<HSECategory> hseCategoryList = new ArrayList<HSECategory>(5);
		try {
			try {
				Long categoryPerPosID = new Long(categoryPerPosIDStr);
				HSECategory hseCategory = hseProblemDao.getHSECategoryByID(categoryPerPosID);
				if (hseCategory != null) {
					if (hseCategory.isOther()) {
						if (Util.isNullOrEmpty(categoryPerPosOther)) {
							request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_OTHER_CONTENT_REQUIRED);
							return false;
						}
						hseCategory.setOtherContent(Util.isoToUTF8(categoryPerPosOther));
					}
					hseCategoryList.add(hseCategory);
				}
			} catch (Exception e) {
			}

			try {
				Long categoryPerEquipID = new Long(categoryPerEquipIDStr);
				HSECategory hseCategory = hseProblemDao.getHSECategoryByID(categoryPerEquipID);
				if (hseCategory != null) {
					if (hseCategory.isOther()) {
						if (Util.isNullOrEmpty(categoryPerEquipOther)) {
							request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_OTHER_CONTENT_REQUIRED);
							return false;
						}
						hseCategory.setOtherContent(Util.isoToUTF8(categoryPerEquipOther));
					}
					hseCategoryList.add(hseCategory);
				}
			} catch (Exception e) {
			}

			try {
				Long categoryWorkActID = new Long(categoryWorkActIDStr);
				HSECategory hseCategory = hseProblemDao.getHSECategoryByID(categoryWorkActID);
				if (hseCategory != null) {
					if (hseCategory.isOther()) {
						if (Util.isNullOrEmpty(categoryWorkActOther)) {
							request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_OTHER_CONTENT_REQUIRED);
							return false;
						}
						hseCategory.setOtherContent(Util.isoToUTF8(categoryWorkActOther));
					}
					hseCategoryList.add(hseCategory);
				}
			} catch (Exception e) {
			}

			try {
				Long categoryToolEquipID = new Long(categoryToolEquipIDStr);
				HSECategory hseCategory = hseProblemDao.getHSECategoryByID(categoryToolEquipID);
				if (hseCategory != null) {
					if (hseCategory.isOther()) {
						if (Util.isNullOrEmpty(categoryToolEquipOther)) {
							request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_OTHER_CONTENT_REQUIRED);
							return false;
						}
						hseCategory.setOtherContent(Util.isoToUTF8(categoryToolEquipOther));
					}
					hseCategoryList.add(hseCategory);
				}
			} catch (Exception e) {
			}

			try {
				Long categoryWorkEnvID = new Long(categoryWorkEnvIDStr);
				HSECategory hseCategory = hseProblemDao.getHSECategoryByID(categoryWorkEnvID);
				if (hseCategory != null) {
					if (hseCategory.isOther()) {
						if (Util.isNullOrEmpty(categoryWorkEnvOther)) {
							request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_OTHER_CONTENT_REQUIRED);
							return false;
						}
						hseCategory.setOtherContent(Util.isoToUTF8(categoryWorkEnvOther));
					}
					hseCategoryList.add(hseCategory);
				}
			} catch (Exception e) {
			}
		} catch (Exception e) {
		}

		Long writerManageGroupID = null;
		if (userDepart2.isManageGroup()) {
			writerManageGroupID = userDepart2.getManageGroupID();
		}

		Set<Long> informedUserIDList = new HashSet<Long>();

		if (!Util.isNullOrEmpty(problemManageGroupUserIDStr)) {
			String[] managegroupUserIDsStr = problemManageGroupUserIDStr.split(",");
			for (String manageGroupUserIDStr : managegroupUserIDsStr) {
				informedUserIDList.add(new Long(manageGroupUserIDStr));
			}
		}

		Role role = userAction.getUserRole(request);
		int intRole = this.calRole(null, null, null, role);
		if ((intRole & (Constants.ROLE_TYPE_ZHUANGZHIZHANG)) == 0) {
			List<User> informedUserList = equipmentDao.getEquipmentZhuangzhizhang(problemEquipID);
			for (User informedUser : informedUserList) {
				informedUserIDList.add(informedUser.getId());
			}

			informedUserList = equipmentDao.getEquipmentMappingUser(problemEquipID, Constants.DEPARTMENT_TYPE_SHIYEBU);
			for (User informedUser : informedUserList) {
				informedUserIDList.add(informedUser.getId());
			}
		}

		Problem problem = new Problem();
		problem.setDepartment1ID(problemDepart1ID);
		problem.setEquipmentID(problemEquipID);
		problem.setProblemContent(Util.isoToUTF8(problemContent));
		problem.setProblemTitle(Util.isoToUTF8(problemTitle));
		problem.setProblemZhenggai(Util.isoToUTF8(problemZhenggai));
		if (isSolvedStr.equals("true")) {
			problem.setSolved(true);
			problem.setProcessStatus(Constants.PROBLEM_STATUS_CLOSE);
		} else {
			problem.setSolved(false);
			problem.setProcessStatus(Constants.PROBLEM_STATUS_ZUZHANG_ZHUANGZHIZHANG);
		}
		problem.setWriteTime(Calendar.getInstance());
		problem.setWriteUserID(user.getId());
		problem.setWriterManageGroupID(writerManageGroupID);
		problem.setWriterDepartment1ID(user.getDepartment1ID());
		problem.setWriterDepartment2ID(user.getDepartment2ID());

		ProblemDao problemDao = DaoCreator.createProblemDao();
		problemDao.addProblem(problem);

		// update problem hse category
		this.deleteAndAddProblemHSECategoryList(problem, hseCategoryList);

		List<Long> informedUserIDlist = new ArrayList<Long>();
		informedUserIDlist.addAll(informedUserIDList);

		// transfer to users
		informedUserIDlist.add(user.getId());
		addTransferInManageGroups(session, user, problem, informedUserIDlist, false, true, null);

		request.setAttribute(Constants.REQUEST_ATTRIBUTE_PROBLEM, problem);
		return true;
	}

	public boolean convertProblem(HttpServletRequest request) {
		String problemTitle = request.getParameter(Constants.REQUEST_PARAMETER_PROBLEM_TITLE);
		String problemContent = request.getParameter(Constants.REQUEST_PARAMETER_PROBLEM_CONTENT);
		String problemZhenggai = request.getParameter(Constants.REQUEST_PARAMETER_ZHENGGAI_CUOSHI);
		String gradeStr = request.getParameter(Constants.REQUEST_PARAMETER_GRADE);
		String completeDateStr = request.getParameter(Constants.REQUEST_PARAMETER_COMPLETE_DATE);
		String postcheckIDStr = request.getParameter(Constants.REQUEST_PARAMETER_POSTCHECK_ID);
		String postcheckPatternIDStr = request.getParameter(Constants.REQUEST_PARAMETER_POSTCHECK_PATTERN_ID);
		String postcheckContentIDStr = request.getParameter(Constants.REQUEST_PARAMETER_POSTCHECK_CONTENT_ID);
		String postcheckStandardIDStr = request.getParameter(Constants.REQUEST_PARAMETER_POSTCHECK_STANDARD_ID);
		String problemIDStr = request.getParameter(Constants.REQUEST_PARAMETER_PROBLEM_ID);
		String isRegularStr = request.getParameter(Constants.REQUEST_PARAMETER_IS_REGULAR);
		Boolean isSanwei = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_IS_SANWEI, Boolean.FALSE);

		HttpSession session = request.getSession();
		User user = (User) session.getAttribute(Constants.SESSION_USER);

		Long postcheckID = null;
		Long postcheckPatternID = null;
		Long postcheckContentID = null;
		Long postcheckStandardID = null;
		Integer grade = null;
		Long problemID = null;
		boolean isRegular = "1".equals(isRegularStr) ? true : false;
		try {
			postcheckID = Long.parseLong(postcheckIDStr);
			postcheckPatternID = Long.parseLong(postcheckPatternIDStr);
			postcheckContentID = Long.parseLong(postcheckContentIDStr);
			postcheckStandardID = Long.parseLong(postcheckStandardIDStr);
			problemID = Long.parseLong(problemIDStr);
		} catch (Exception e) {
		}

		grade = ValueUtil.getGrade(gradeStr);

		if (!Util.isNullOrEmpty(problemTitle)) {
			problemTitle = Util.isoToUTF8(problemTitle);
		}

		if (!Util.isNullOrEmpty(problemContent)) {
			problemContent = Util.isoToUTF8(problemContent);
		}

		if (!Util.isNullOrEmpty(problemZhenggai)) {
			problemZhenggai = Util.isoToUTF8(problemZhenggai);
		}

		ProblemDao problemDao = DaoCreator.createProblemDao();
		Problem problem = problemDao.getProblemByID(problemID);
		problem.setSolved(isRegular);
		problem.setSanwei(isSanwei);

		if (grade == 0 && isRegular) {
			List<ProblemTransfer> transferLst = problemDao.getProblemTransferByProblemID(problemID);
			Long transferID = null;
			for (ProblemTransfer transfer : transferLst) {
				if (transfer.getTransferedUserID().equals(user.getId())) {
					transferID = transfer.getId();
					break;
				}
			}
			problemDao.processProblem(MessageUtil.getMessage(Constants.PROCESS_METHOD_CONVERT_LABEL), transferID, problemID, user.getId(),
					Constants.PROBLEM_STATUS_CLOSE, Constants.PROCESS_METHOD_CONVERT, null, problem.getEscalateDepart1ID(), grade, false);

			problemDao.updateProblem(problem.getId(), Constants.PROBLEM_TYPE_POSTCHECK, problemTitle, problemContent, problemZhenggai,
					grade, postcheckID, postcheckPatternID, postcheckContentID, postcheckStandardID,
					Util.convertStrToDate(completeDateStr), Constants.PROBLEM_STATUS_CLOSE);
			problemDao.updateProblem(problem.getId(), Constants.COLUMN_NAME_IS_SOLVED, Boolean.TRUE);
			problemDao.updateProblem(problem.getId(), Constants.COLUMN_NAME_IS_SANWEI, isSanwei);
		} else {
			problemDao.updateProblem(problem.getId(), Constants.PROBLEM_TYPE_POSTCHECK, problemTitle, problemContent, problemZhenggai,
					grade, postcheckID, postcheckPatternID, postcheckContentID, postcheckStandardID,
					Util.convertStrToDate(completeDateStr), Constants.PROBLEM_STATUS_ZUZHANG_ZHUANGZHIZHANG);
			problemDao.updateProblem(problem.getId(), Constants.COLUMN_NAME_IS_SOLVED, isRegular);
			problemDao.updateProblem(problem.getId(), Constants.COLUMN_NAME_IS_SANWEI, isSanwei);
			problemDao.updateProblemTransfer(problemID, false);

			List<ProblemTransfer> transferLst = problemDao.getProblemTransferByProblemID(problemID);
			Long transferID = null;
			for (ProblemTransfer transfer : transferLst) {
				if (transfer.getTransferedUserID().equals(user.getId())) {
					transferID = transfer.getId();
					break;
				}
			}
			problemDao.processProblem(MessageUtil.getMessage(Constants.PROCESS_METHOD_CONVERT_LABEL), transferID, problemID, user.getId(),
					Constants.PROBLEM_STATUS_ZUZHANG_ZHUANGZHIZHANG, Constants.PROCESS_METHOD_CONVERT, null,
					problem.getEscalateDepart1ID(), grade, false);
		}

		int[] currentDate = Util.getCurrentDate();

		session.getServletContext().removeAttribute(
				Constants.APPLICATION_POSTCHECK_SUMMARY_REPORT_TABLE + "_" + postcheckID + "_" + currentDate[0] + "_" + currentDate[1]);
		return true;
	}

	public boolean writePostcheck(HttpServletRequest request) {
		String problemTitle = request.getParameter(Constants.REQUEST_PARAMETER_PROBLEM_TITLE);
		String problemContent = request.getParameter(Constants.REQUEST_PARAMETER_PROBLEM_CONTENT);
		String problemZhenggai = request.getParameter(Constants.REQUEST_PARAMETER_ZHENGGAI_CUOSHI);
		String problemDepart1IDStr = request.getParameter(Constants.REQUEST_PARAMETER_DEPARTMENT1ID);
		String problemEquipIDStr = request.getParameter(Constants.REQUEST_PARAMETER_EQUIP_ID);
		String problemManageGroupUserIDStr = request.getParameter(Constants.REQUEST_PARAMETER_USER_ID);
		String gradeStr = request.getParameter(Constants.REQUEST_PARAMETER_GRADE);
		String completeDateStr = request.getParameter(Constants.REQUEST_PARAMETER_COMPLETE_DATE);
		String postcheckIDStr = request.getParameter(Constants.REQUEST_PARAMETER_POSTCHECK_ID);
		String postcheckPatternIDStr = request.getParameter(Constants.REQUEST_PARAMETER_POSTCHECK_PATTERN_ID);
		String postcheckContentIDStr = request.getParameter(Constants.REQUEST_PARAMETER_POSTCHECK_CONTENT_ID);
		String postcheckStandardIDStr = request.getParameter(Constants.REQUEST_PARAMETER_POSTCHECK_STANDARD_ID);
		String isRegularStr = request.getParameter(Constants.REQUEST_PARAMETER_IS_REGULAR);
		Boolean isSanwei = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_IS_SANWEI, Boolean.FALSE);

		HttpSession session = request.getSession();
		User user = (User) session.getAttribute(Constants.SESSION_USER);

		EquipmentDao equipmentDao = DaoCreator.createEquipmentDao();
		DepartmentDao departmentDao = DaoCreator.createDepartmentDao();

		UserAction userAction = ActionCreator.createUserAction();

		Long postcheckID = null;
		Long postcheckPatternID = null;
		Long postcheckContentID = null;
		Long postcheckStandardID = null;
		Integer grade = null;
		boolean isRegular = "1".equals(isRegularStr) ? true : false;

		try {
			postcheckID = Long.parseLong(postcheckIDStr);
			postcheckPatternID = Long.parseLong(postcheckPatternIDStr);
			postcheckContentID = Long.parseLong(postcheckContentIDStr);
			postcheckStandardID = Long.parseLong(postcheckStandardIDStr);
		} catch (Exception e) {
		}

		grade = ValueUtil.getGrade(gradeStr);

		Long problemDepart1ID = 0L;
		try {
			problemDepart1ID = new Long(problemDepart1IDStr);
		} catch (Exception e) {
			problemDepart1ID = user.getDepartment1ID();
		}

		Department2 userDepart2 = departmentDao.getDepartment2ByID(user.getDepartment2ID());
		Long problemEquipID = 0L;
		try {
			problemEquipID = new Long(problemEquipIDStr);
		} catch (Exception e) {
			if (userDepart2.isEquip()) {
				problemEquipID = userDepart2.getEquipID();
			}
		}

		List<Long> informedUserIDList = new ArrayList<Long>();

		if (!Util.isNullOrEmpty(problemManageGroupUserIDStr)) {
			String[] managegroupUserIDsStr = problemManageGroupUserIDStr.split(",");
			for (String manageGroupUserIDStr : managegroupUserIDsStr) {
				informedUserIDList.add(new Long(manageGroupUserIDStr));
			}
		}

		Role role = userAction.getUserRole(request);
		int intRole = this.calRole(null, null, null, role);
		if ((intRole & (Constants.ROLE_TYPE_ZHUANGZHIZHANG)) == 0) {
			List<User> informedUserList = equipmentDao.getEquipmentZhuangzhizhang(problemEquipID);
			for (User informedUser : informedUserList) {
				informedUserIDList.add(informedUser.getId());
			}

			informedUserList = equipmentDao.getEquipmentMappingUser(problemEquipID, Constants.DEPARTMENT_TYPE_SHIYEBU);
			for (User informedUser : informedUserList) {
				informedUserIDList.add(informedUser.getId());
			}
		}

		Problem problem = new Problem();
		problem.setDepartment1ID(problemDepart1ID);
		problem.setEquipmentID(problemEquipID);
		problem.setProblemContent(Util.isoToUTF8(problemContent));
		problem.setProblemTitle(Util.isoToUTF8(problemTitle));
		problem.setProblemZhenggai(Util.isoToUTF8(problemZhenggai));
		problem.setProcessStatus(Constants.PROBLEM_STATUS_ZUZHANG_ZHUANGZHIZHANG);
		problem.setWriteTime(Calendar.getInstance());
		problem.setWriteUserID(user.getId());

		// information of postcheck
		problem.setProblemType(Constants.PROBLEM_TYPE_POSTCHECK);
		problem.setPostcheckID(postcheckID);
		problem.setPostcheckPatternID(postcheckPatternID);
		problem.setPostcheckContentID(postcheckContentID);
		problem.setPostcheckStandardID(postcheckStandardID);
		problem.setGrade(grade);
		problem.setCompleteDate(Util.convertStrToDate(completeDateStr));
		problem.setWriterDepartment1ID(user.getDepartment1ID());
		problem.setWriterDepartment2ID(user.getDepartment2ID());
		problem.setSolved(isRegular);
		problem.setSanwei(isSanwei);

		ProblemDao problemDao = DaoCreator.createProblemDao();

		if (grade == 0 && isRegular) {
			problem.setProcessStatus(Constants.PROBLEM_STATUS_CLOSE);

		}

		problemDao.addPostcheckProblem(problem);

		// transfer to users
		informedUserIDList.add(user.getId());
		addTransferInManageGroups(session, user, problem, informedUserIDList, false, true, null);

		int[] currentDate = Util.getCurrentDate();

		session.getServletContext().removeAttribute(
				Constants.APPLICATION_POSTCHECK_SUMMARY_REPORT_TABLE + "_" + postcheckID + "_" + currentDate[0] + "_" + currentDate[1]);
		return true;
	}

	public boolean feedbackProblem(HttpServletRequest request) {
		String problemIDStr = request.getParameter(Constants.REQUEST_PARAMETER_ID);
		String transferIDStr = request.getParameter(Constants.REQUEST_PARAMETER_TRANSFER_ID);

		return this.feedbackProblem(request, problemIDStr, transferIDStr);
	}

	public boolean feedbackProblem(HttpServletRequest request, String problemIDStr, String transferIDStr) {
		HttpSession session = request.getSession();

		String processMethodStr = request.getParameter(Constants.REQUEST_PARAMETER_PROCESS_METHOD);
		String feedback = request.getParameter(Constants.REQUEST_PARAMETER_FEEDBACK);
		String problemManageGroupUserIDStr = request.getParameter(Constants.REQUEST_PARAMETER_USER_ID);
		String gradeStr = request.getParameter(Constants.REQUEST_PARAMETER_GRADE);
		String categoryPerPosIDStr = request.getParameter(Constants.REQUEST_PARAMETER_CATEGORY_PERSON_POSITION_ID);
		String categoryPerEquipIDStr = request.getParameter(Constants.REQUEST_PARAMETER_CATEGORY_PERSON_EQUIP_ID);
		String categoryWorkActIDStr = request.getParameter(Constants.REQUEST_PARAMETER_CATEGORY_WORK_ACTIVITY_ID);
		String categoryToolEquipIDStr = request.getParameter(Constants.REQUEST_PARAMETER_CATEGORY_TOOL_EQUIP_ID);
		String categoryWorkEnvIDStr = request.getParameter(Constants.REQUEST_PARAMETER_CATEGORY_WORK_ENVIRONMENT_ID);
		String categoryPerPosOther = request.getParameter(Constants.REQUEST_PARAMETER_CATEGORY_PERSON_POSITION_OTHER);
		String categoryPerEquipOther = request.getParameter(Constants.REQUEST_PARAMETER_CATEGORY_PERSON_EQUIP_OTHER);
		String categoryWorkActOther = request.getParameter(Constants.REQUEST_PARAMETER_CATEGORY_WORK_ACTIVITY_OTHER);
		String categoryToolEquipOther = request.getParameter(Constants.REQUEST_PARAMETER_CATEGORY_TOOL_EQUIP_OTHER);
		String categoryWorkEnvOther = request.getParameter(Constants.REQUEST_PARAMETER_CATEGORY_WORK_ENVIRONMENT_OTHER);

		if (feedback != null) {
			feedback = feedback.trim();
			feedback = Util.isoToUTF8(feedback);
		}

		int processMethod = 0;
		try {
			processMethod = Integer.parseInt(processMethodStr);
		} catch (Exception e) {
		}

		Long problemID = 0L;
		try {
			problemID = new Long(problemIDStr);
		} catch (Exception e) {
		}

		Long transferID = 0L;
		try {
			transferID = new Long(transferIDStr);
		} catch (Exception e) {
		}

		Integer grade = ValueUtil.getGrade(gradeStr);

		HSEProblemDao hseProblemDao = DaoCreator.createHSEProblemDao();
		List<HSECategory> hseCategoryList = new ArrayList<HSECategory>(5);
		try {
			try {
				Long categoryPerPosID = new Long(categoryPerPosIDStr);
				HSECategory hseCategory = hseProblemDao.getHSECategoryByID(categoryPerPosID);
				if (hseCategory != null) {
					if (hseCategory.isOther()) {
						hseCategory.setOtherContent(Util.isoToUTF8(categoryPerPosOther));
					}
					hseCategoryList.add(hseCategory);
				}
			} catch (Exception e) {
			}

			try {
				Long categoryPerEquipID = new Long(categoryPerEquipIDStr);
				HSECategory hseCategory = hseProblemDao.getHSECategoryByID(categoryPerEquipID);
				if (hseCategory != null) {
					if (hseCategory.isOther()) {
						hseCategory.setOtherContent(Util.isoToUTF8(categoryPerEquipOther));
					}
					hseCategoryList.add(hseCategory);
				}
			} catch (Exception e) {
			}

			try {
				Long categoryWorkActID = new Long(categoryWorkActIDStr);
				HSECategory hseCategory = hseProblemDao.getHSECategoryByID(categoryWorkActID);
				if (hseCategory != null) {
					if (hseCategory.isOther()) {
						hseCategory.setOtherContent(Util.isoToUTF8(categoryWorkActOther));
					}
					hseCategoryList.add(hseCategory);
				}
			} catch (Exception e) {
			}

			try {
				Long categoryToolEquipID = new Long(categoryToolEquipIDStr);
				HSECategory hseCategory = hseProblemDao.getHSECategoryByID(categoryToolEquipID);
				if (hseCategory != null) {
					if (hseCategory.isOther()) {
						hseCategory.setOtherContent(Util.isoToUTF8(categoryToolEquipOther));
					}
					hseCategoryList.add(hseCategory);
				}
			} catch (Exception e) {
			}

			try {
				Long categoryWorkEnvID = new Long(categoryWorkEnvIDStr);
				HSECategory hseCategory = hseProblemDao.getHSECategoryByID(categoryWorkEnvID);
				if (hseCategory != null) {
					if (hseCategory.isOther()) {
						hseCategory.setOtherContent(Util.isoToUTF8(categoryWorkEnvOther));
					}
					hseCategoryList.add(hseCategory);
				}
			} catch (Exception e) {
			}
		} catch (Exception e) {
		}

		UserAction userAction = ActionCreator.createUserAction();

		// check where user has right to process this problem
		User user = (User) session.getAttribute(Constants.SESSION_USER);
		ProblemDao problemDao = DaoCreator.createProblemDao();
		EquipmentDao equipmentDao = DaoCreator.createEquipmentDao();
		DepartmentDao departmentDao = DaoCreator.createDepartmentDao();
		UserDao userDao = DaoCreator.createUserDao();

		Problem problem = problemDao.getProblemByID(problemID);
		if (grade == null) {
			grade = problem.getGrade();
		}
		ProblemTransfer problemTransfer = problemDao.getProblemTransferByID(transferID);

		TitlePostManageGroupDao postDao = DaoCreator.createTitlePostManageGroupDao();
		JobPost post1 = postDao.getJobPostByID(user.getJobPost1ID());
		JobPost post2 = postDao.getJobPostByID(user.getJobPost2ID());
		JobPost post3 = postDao.getJobPostByID(user.getJobPost3ID());
		Role role = userAction.getUserRole(request);

		boolean hasRight = this.hasRightToFeedback(problem, user, transferID, post1, post2, post3, role, processMethod);
		if (!hasRight) {
			request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_HAS_NOT_RIGHT_TO_PROCESS);
			return false;
		}

		// write feedback
		int intRole = this.calRole(post1, post2, post3, role);
		if (processMethod == Constants.PROCESS_METHOD_FEEDBACK) {
			if ((intRole & Constants.ROLE_TYPE_ZUYUAN) > 0) {
				boolean isMainProcessor = problemDao.isMainProblemProcessor(user.getId(), problem.getId(), transferID);
				problemDao.processProblem(feedback, transferID, problemID, user.getId(), problem.getProcessStatus(),
						Constants.PROCESS_METHOD_FEEDBACK, null, problem.getEscalateDepart1ID(), grade, problem.isProcessingByChushi());
				// update problem hse category
				this.deleteAndAddProblemHSECategoryList(problem, hseCategoryList);

				if (isMainProcessor) {
					List<ProblemTransfer> transferList = new ArrayList<ProblemTransfer>(1);
					ProblemTransfer transfer = new ProblemTransfer();
					transfer.setUserID(user.getId());
					transfer.setTransferedUserID(problemTransfer.getUserID());
					transfer.setProcessed(false);
					transfer.setProblemID(problem.getId());
					transfer.setMainTransferUser(true);
					transferList.add(transfer);

					problemDao.addProblemTransfers(transferList);
				}
			} else if ((intRole & Constants.ROLE_TYPE_KEYUAN) > 0) {
				problemDao.processProblem(feedback, transferID, problemID, user.getId(), problem.getProcessStatus(),
						Constants.PROCESS_METHOD_FEEDBACK, null, problem.getEscalateDepart1ID(), grade, problem.isProcessingByChushi());
				// update problem hse category
				this.deleteAndAddProblemHSECategoryList(problem, hseCategoryList);

				List<User> kezhangs = departmentDao.getUserIDsByDepartment2IDandRoleType(user.getDepartment2ID(),
						Constants.ROLE_TYPE_KEZHANG | Constants.ROLE_TYPE_FUKEZHANG);
				List<ProblemTransfer> transferList = new ArrayList<ProblemTransfer>(2);
				for (User kezhang : kezhangs) {
					ProblemTransfer transfer = new ProblemTransfer();
					transfer.setUserID(user.getId());
					transfer.setTransferedUserID(kezhang.getId());
					transfer.setProcessed(false);
					transfer.setProblemID(problem.getId());
					transfer.setMainTransferUser(true);

					transferList.add(transfer);
				}
				problemDao.addProblemTransfers(transferList);
			} else if ((intRole & (Constants.ROLE_TYPE_KEZHANG | Constants.ROLE_TYPE_FUKEZHANG)) > 0) {
				problemDao.processProblem(feedback, transferID, problemID, user.getId(), problem.getProcessStatus(),
						Constants.PROCESS_METHOD_FEEDBACK, null, problem.getEscalateDepart1ID(), grade, problem.isProcessingByChushi());
				// update problem hse category
				this.deleteAndAddProblemHSECategoryList(problem, hseCategoryList);

				List<User> chuzhangs = departmentDao.getUserIDsByDepartment2IDandRoleType(user.getDepartment2ID(),
						Constants.ROLE_TYPE_FUCHUZHANG | Constants.ROLE_TYPE_CHUZHANG);
				List<ProblemTransfer> transferList = new ArrayList<ProblemTransfer>(2);
				for (User chuzhang : chuzhangs) {
					ProblemTransfer transfer = new ProblemTransfer();
					transfer.setUserID(user.getId());
					transfer.setTransferedUserID(chuzhang.getId());
					transfer.setProcessed(false);
					transfer.setProblemID(problem.getId());
					transfer.setMainTransferUser(true);

					transferList.add(transfer);
				}
				problemDao.addProblemTransfers(transferList);
			} else {
				request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_PROCESS_METHOD_ACQUIRED);
				return false;
			}
		} else if (processMethod == Constants.PROCESS_METHOD_CLOSE) {
			// check if closer has higher role
			User problemWriter = userDao.getUserByID(problem.getWriteUserID());
			if (!this.hasRightToClose(user, problemWriter, problem)) {
				request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_NO_RIGHT_TO_CLOSE);
				return false;
			}

			problemDao.processProblem(feedback, transferID, problemID, user.getId(), Constants.PROBLEM_STATUS_CLOSE,
					Constants.PROCESS_METHOD_CLOSE, null, problem.getEscalateDepart1ID(), grade, problem.isProcessingByChushi());
			// update problem hse category
			this.deleteAndAddProblemHSECategoryList(problem, hseCategoryList);
		} else if (processMethod == Constants.PROCESS_METHOD_TRANSFER) {
			List<Long> informedUserIDList = new ArrayList<Long>();

			String[] manageGroupUserIDStrArr = problemManageGroupUserIDStr.split(",");
			for (String userIDStr : manageGroupUserIDStrArr) {
				try {
					Long userID = new Long(userIDStr);
					informedUserIDList.add(userID);
				} catch (Exception e) {
				}
			}

			if (informedUserIDList.contains(user.getId())) {
				request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_INFORMED_USER_REPEATED);
				return false;
			}

			if ((intRole & Constants.ROLE_TYPE_ZUZHANG) > 0) {
				// transfer to zuyuan
				List<ProblemTransfer> transferList = this.addTransferInManageGroups(session, user, problem, informedUserIDList, true,
						false, transferID);

				problemDao.processProblem(feedback, transferID, problemID, user.getId(), Constants.PROBLEM_STATUS_ZUYUAN,
						Constants.PROCESS_METHOD_TRANSFER, transferList, problem.getEscalateDepart1ID(), grade,
						problem.isProcessingByChushi());
				// update problem hse category
				this.deleteAndAddProblemHSECategoryList(problem, hseCategoryList);
			} else if ((intRole & (Constants.ROLE_TYPE_ZHUANGZHIZHANG | Constants.ROLE_TYPE_BUZHANG
					| Constants.ROLE_TYPE_SHENGCHANFUBUZHANG | Constants.ROLE_TYPE_SHEBEIFUBUZHANG | Constants.ROLE_TYPE_ANQUANZONGJIAN)) > 0) {
				// transfer to zuzhang, zuyuan
				List<ProblemTransfer> transferList = this.addTransferInManageGroups(session, user, problem, informedUserIDList, true,
						false, transferID);

				problemDao.processProblem(feedback, transferID, problemID, user.getId(), Constants.PROBLEM_STATUS_ZUZHANG_ZHUANGZHIZHANG,
						Constants.PROCESS_METHOD_TRANSFER, transferList, problem.getEscalateDepart1ID(), grade,
						problem.isProcessingByChushi());
				// update problem hse category
				this.deleteAndAddProblemHSECategoryList(problem, hseCategoryList);
			} else if ((intRole & (Constants.ROLE_TYPE_CHUZHANG | Constants.ROLE_TYPE_FUCHUZHANG)) > 0) {
				session.removeAttribute(Constants.SESSION_MANAGE_GROUP_USER);
				Set<Long> informedUserIDSet = new HashSet<Long>();
				Set<Long> depart2IDSet = new HashSet<Long>();

				// get checked user
				String userIDsStr = request.getParameter(Constants.REQUEST_PARAMETER_USER_ID);
				String[] userIDsArr = userIDsStr.split(",");
				for (String userIDStr : userIDsArr) {
					try {
						Long userID = new Long(userIDStr);
						informedUserIDSet.add(userID);

						User depart2User = userDao.getUserByID(userID);
						depart2IDSet.add(depart2User.getDepartment2ID());
					} catch (Exception e) {
					}
				}

				// inform kezhang and fukezhang of the depart2 (equipment)
				for (Long depart2ID : depart2IDSet) {
					List<User> transferUserList = departmentDao.getUserIDsByDepartment2IDandRoleType(depart2ID, Constants.ROLE_TYPE_KEZHANG
							| Constants.ROLE_TYPE_FUKEZHANG);
					for (User kezhang : transferUserList) {
						informedUserIDSet.add(kezhang.getId());
					}
				}

				List<ProblemTransfer> transferList = new ArrayList<ProblemTransfer>();
				for (Long transferUserID : informedUserIDSet) {
					ProblemTransfer transfer = new ProblemTransfer();
					transfer.setUserID(user.getId());
					transfer.setTransferedUserID(transferUserID);
					transfer.setProcessed(false);
					transfer.setProblemID(problem.getId());
					transfer.setMainTransferUser(true);

					transferList.add(transfer);
				}
				problemDao.addProblemTransfers(transferList);

				problemDao.processProblem(feedback, transferID, problemID, user.getId(), Constants.PROBLEM_STATUS_FUKEZHANG,
						Constants.PROCESS_METHOD_TRANSFER, transferList, problem.getEscalateDepart1ID(), grade,
						problem.isProcessingByChushi());
				// update problem hse category
				this.deleteAndAddProblemHSECategoryList(problem, hseCategoryList);
			} else if ((intRole & (Constants.ROLE_TYPE_FUKEZHANG | Constants.ROLE_TYPE_KEZHANG)) > 0) {
				List<ProblemTransfer> transferList = this.addTransferInManageGroups(session, user, problem, informedUserIDList, true,
						false, transferID);

				problemDao.processProblem(feedback, transferID, problemID, user.getId(), Constants.PROBLEM_STATUS_KEYUAN,
						Constants.PROCESS_METHOD_TRANSFER, transferList, problem.getEscalateDepart1ID(), grade,
						problem.isProcessingByChushi());
				// update problem hse category
				this.deleteAndAddProblemHSECategoryList(problem, hseCategoryList);
			} else if ((intRole & (Constants.ROLE_TYPE_KEYUAN)) > 0) {
				List<ProblemTransfer> transferList = this.addTransferInManageGroups(session, user, problem, informedUserIDList, true,
						false, transferID);

				problemDao.processProblem(feedback, transferID, problemID, user.getId(), Constants.PROBLEM_STATUS_KEYUAN,
						Constants.PROCESS_METHOD_TRANSFER, transferList, problem.getEscalateDepart1ID(), grade,
						problem.isProcessingByChushi());
				// update problem hse category
				this.deleteAndAddProblemHSECategoryList(problem, hseCategoryList);
			}
		} else if (processMethod == Constants.PROCESS_METHOD_SENDBACK) {
			session.removeAttribute(Constants.SESSION_MANAGE_GROUP_USER);

			if (!this.hasRightToSendback(user, problem)) {
				request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_HAS_NOT_RIGHT_TO_SENDBACK);
				return false;
			}

			if ((intRole & (Constants.ROLE_TYPE_ANQUANZONGJIAN | Constants.ROLE_TYPE_SHEBEIFUBUZHANG
					| Constants.ROLE_TYPE_SHENGCHANFUBUZHANG | Constants.ROLE_TYPE_BUZHANG)) > 0) {
				problemDao.processProblem(feedback, transferID, problemID, user.getId(), Constants.PROBLEM_STATUS_ZUZHANG_ZHUANGZHIZHANG,
						Constants.PROCESS_METHOD_SENDBACK, null, problem.getEscalateDepart1ID(), grade, false);
				// update problem hse category
				this.deleteAndAddProblemHSECategoryList(problem, hseCategoryList);

				List<User> informedUserList = equipmentDao.getEquipmentMappingUser(problem.getEquipmentID(),
						Constants.DEPARTMENT_TYPE_SHIYEBU);
				List<Long> informedUserIDList = new ArrayList<Long>();
				informedUserIDList.add(user.getId());
				for (User informedUser : informedUserList) {
					informedUserIDList.add(informedUser.getId());
				}

				informedUserList = equipmentDao.getEquipmentZhuangzhizhang(problem.getEquipmentID());
				for (User informedUser : informedUserList) {
					informedUserIDList.add(informedUser.getId());
				}

				List<Long> zuzhangList = problemDao.getTransferRoleUserByTransferedUserID(problemID, Constants.ROLE_TYPE_ZUZHANG);
				for (Long zuzhangID : zuzhangList) {
					if (!user.getId().equals(zuzhangID)) {
						informedUserIDList.add(zuzhangID);
					}
				}

				this.addTransferInManageGroups(session, user, problem, informedUserIDList, true, false, transferID);
			} else if ((intRole & (Constants.ROLE_TYPE_CHUZHANG | Constants.ROLE_TYPE_FUCHUZHANG)) > 0) {
				List<Long> informedUserIDList = new ArrayList<Long>();
				Department1 problemWriterDepart1 = departmentDao.getDepart1ByUserID(problem.getWriteUserID());

				if (problemWriterDepart1.getDepartmentType() == Constants.DEPARTMENT_TYPE_JIGUAN) {
					problemDao.processProblem(feedback, transferID, problemID, user.getId(), Constants.PROBLEM_STATUS_FUKEZHANG,
							Constants.PROCESS_METHOD_SENDBACK, null, problem.getEscalateDepart1ID(), grade, false);
					// update problem hse category
					this.deleteAndAddProblemHSECategoryList(problem, hseCategoryList);

					List<Long> kezhangList = problemDao.getTransferRoleUserByTransferedUserID(problemID, Constants.ROLE_TYPE_KEZHANG
							| Constants.ROLE_TYPE_FUKEZHANG);
					informedUserIDList.add(user.getId());
					informedUserIDList.addAll(kezhangList);
				} else {
					problemDao.processProblem(feedback, transferID, problemID, user.getId(), Constants.PROBLEM_STATUS_BUZHANG,
							Constants.PROCESS_METHOD_SENDBACK, null, problem.getEscalateDepart1ID(), grade, false);
					// update problem hse category
					this.deleteAndAddProblemHSECategoryList(problem, hseCategoryList);

					List<Long> buzhangList = problemDao.getTransferRoleUserByTransferedUserID(problemID, Constants.ROLE_TYPE_BUZHANG);
					informedUserIDList.add(user.getId());
					informedUserIDList.addAll(buzhangList);
				}

				this.addTransferInManageGroups(session, user, problem, informedUserIDList, true, false, transferID);
			} else if (this.isLingDaoBanzi(post1, post2, post3, role)) {
				problemDao.processProblem(feedback, transferID, problemID, user.getId(), Constants.PROBLEM_STATUS_CHUZHANG,
						Constants.PROCESS_METHOD_SENDBACK, null, problem.getEscalateDepart1ID(), grade, false);
				// update problem hse category
				this.deleteAndAddProblemHSECategoryList(problem, hseCategoryList);

				List<Long> informedUserIDList = new ArrayList<Long>();
				informedUserIDList.add(user.getId());
				this.addTransferInManageGroups(session, user, problem, informedUserIDList, true, false, transferID);
			}
		} else if (processMethod == Constants.PROCESS_METHOD_ESCALATE) {
			if ((role.getRoleType() & (Constants.ROLE_TYPE_BUZHANG)) == 0) {
				User escalateUser = (User) session.getAttribute(Constants.SESSION_ESCALATE_USER);
				if (escalateUser == null) {
					request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_ESCALATE_USER_ACQUIRED);
					return false;
				}

				problemDao.processProblem(feedback, transferID, problemID, user.getId(), Constants.PROBLEM_STATUS_BUZHANG,
						Constants.PROCESS_METHOD_ESCALATE, null, problem.getEscalateDepart1ID(), grade, false);
				// update problem hse category
				this.deleteAndAddProblemHSECategoryList(problem, hseCategoryList);

				List<ProblemTransfer> transferList = new ArrayList<ProblemTransfer>(1);
				ProblemTransfer transfer = new ProblemTransfer();
				transfer.setUserID(user.getId());
				transfer.setTransferedUserID(escalateUser.getId());
				transfer.setProcessed(false);
				transfer.setProblemID(problem.getId());
				transfer.setMainTransferUser(true);
				transferList.add(transfer);

				problemDao.addProblemTransfers(transferList);
			} else {
				Department1 depart1 = (Department1) session.getAttribute(Constants.SESSION_PROBLEM_DEPARTMENT1);
				if (depart1 == null) {
					request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_ESCALATE_DEPART1_ACQUIRED);
					return false;
				}

				problemDao.processProblem(feedback, transferID, problemID, user.getId(), Constants.PROBLEM_STATUS_FUCHUZHANG,
						Constants.PROCESS_METHOD_ESCALATE, null, depart1.getId(), grade, true);
				// update problem hse category
				this.deleteAndAddProblemHSECategoryList(problem, hseCategoryList);

				List<User> chuzhangs = departmentDao.getUserIDsByDepartment1IDandRoleType(depart1.getId(), Constants.ROLE_TYPE_CHUZHANG
						| Constants.ROLE_TYPE_FUCHUZHANG);

				List<Long> informedUserIDList = new ArrayList<Long>();
				for (User chuzhang : chuzhangs) {
					informedUserIDList.add(chuzhang.getId());
				}

				this.addTransferInManageGroups(session, user, problem, informedUserIDList, true, false, transferID);
			}
		} else if (processMethod == Constants.PROCESS_METHOD_OTHERDEPART) {
			if ((intRole & (Constants.ROLE_TYPE_KEZHANG | Constants.ROLE_TYPE_FUKEZHANG | Constants.ROLE_TYPE_KEYUAN | Constants.ROLE_TYPE_FUCHUZHANG)) > 0) {
				User escalateUser = (User) session.getAttribute(Constants.SESSION_ESCALATE_USER);
				if (escalateUser == null) {
					request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_ESCALATE_USER_ACQUIRED);
					return false;
				}

				List<Long> informedUserIDList = new ArrayList<Long>();
				informedUserIDList.add(escalateUser.getId());
				informedUserIDList.add(user.getId());

				this.addTransferInManageGroups(session, user, problem, informedUserIDList, true, false, transferID);

				problemDao.processProblem(feedback, transferID, problemID, user.getId(), Constants.PROBLEM_STATUS_OTHER_DEPART_HELP,
						Constants.PROCESS_METHOD_OTHERDEPART, null, problem.getEscalateDepart1ID(), grade, problem.isProcessingByChushi());
				// update problem hse category
				this.deleteAndAddProblemHSECategoryList(problem, hseCategoryList);
			} else {
				List<Department1> depart1List = (List<Department1>) session.getAttribute(Constants.SESSION_PROBLEM_DEPARTMENT1);
				List<User> chuzhangs = new ArrayList<User>();
				for (Department1 depart1 : depart1List) {
					chuzhangs.addAll(departmentDao.getUserIDsByDepartment1IDandRoleType(depart1.getId(), Constants.ROLE_TYPE_CHUZHANG
							| Constants.ROLE_TYPE_FUCHUZHANG | Constants.ROLE_TYPE_BUZHANG));
				}

				List<Long> informedUserIDList = new ArrayList<Long>();
				for (User chuzhang : chuzhangs) {
					informedUserIDList.add(chuzhang.getId());
				}
				informedUserIDList.add(user.getId());

				this.addTransferInManageGroups(session, user, problem, informedUserIDList, true, false, transferID);

				problemDao.processProblem(feedback, transferID, problemID, user.getId(), Constants.PROBLEM_STATUS_OTHER_DEPART_HELP,
						Constants.PROCESS_METHOD_OTHERDEPART, null, problem.getEscalateDepart1ID(), grade, problem.isProcessingByChushi());
				// update problem hse category
				this.deleteAndAddProblemHSECategoryList(problem, hseCategoryList);
			}
		} else if (processMethod == Constants.PROCESS_METHOD_PROVE) {
			problemDao.processProblem(feedback, transferID, problemID, user.getId(), Constants.PROBLEM_STATUS_PROVED,
					Constants.PROCESS_METHOD_PROVE, null, problem.getEscalateDepart1ID(), grade, problem.isProcessingByChushi());
			// update problem hse category
			this.deleteAndAddProblemHSECategoryList(problem, hseCategoryList);
		}

		return true;
	}

	protected List<ProblemTransfer> addTransferInManageGroups(HttpSession session, User user, Problem problem,
			List<Long> informedUserIDList, boolean isMainProcessor, boolean isFirstSent, Long transferID) {
		Map<Long, Set<Long>> map = (Map<Long, Set<Long>>) session.getAttribute(Constants.SESSION_MANAGE_GROUP_USER);
		if (map != null) {
			Set<Entry<Long, Set<Long>>> entrySet = map.entrySet();
			for (Entry<Long, Set<Long>> entry : entrySet) {
				Set<Long> idSet = entry.getValue();
				for (Long userID : idSet) {
					informedUserIDList.add(userID);
				}
			}
		}
		List<ProblemTransfer> transferList = new ArrayList<ProblemTransfer>();
		for (Long informedUserID : informedUserIDList) {
			ProblemTransfer transfer = new ProblemTransfer();
			transfer.setUserID(user.getId());
			transfer.setTransferedUserID(informedUserID);
			transfer.setProcessed(false);
			transfer.setProblemID(problem.getId());
			transfer.setMainTransferUser(isMainProcessor);
			transfer.setFirstSent(isFirstSent);
			transfer.setForwardMappingTransferID(transferID);

			transferList.add(transfer);
		}

		ProblemDao problemDao = DaoCreator.createProblemDao();
		problemDao.addProblemTransfers(transferList);

		session.removeAttribute(Constants.SESSION_MANAGE_GROUP_USER);

		return transferList;
	}

	public void deleteAndAddProblemHSECategoryList(Problem problem, List<HSECategory> hseCategoryList) {
		HSEProblemDao hseProblemDao = DaoCreator.createHSEProblemDao();
		boolean deleteSuccess = hseProblemDao.deleteProblemHSECategory(problem.getId());
		if (deleteSuccess) {
			for (HSECategory hseCategory : hseCategoryList) {
				ProblemHSECategory problemHSECategory = new ProblemHSECategory();
				problemHSECategory.setProblemID(problem.getId());
				problemHSECategory.setDirectCauseID(hseCategory.getDirectCauseID());
				problemHSECategory.setHseCategoryID(hseCategory.getId());
				problemHSECategory.setHseCategoryType(hseCategory.getCategoryType());
				if (hseCategory.isOther()) {
					problemHSECategory.setOther(hseCategory.getOtherContent());
				}
				problemHSECategory.setRemoteCauseID(hseCategory.getRemoteCauseID());

				hseProblemDao.addProblemHSECategory(problemHSECategory);
			}
		}
	}

	public String getSessionManageGroupUserStr(HttpSession session) {
		StringBuilder sb = new StringBuilder();
		UserDao userDao = DaoCreator.createUserDao();

		Map<Long, Set<Long>> map = (Map<Long, Set<Long>>) session.getAttribute(Constants.SESSION_MANAGE_GROUP_USER);
		if (map != null) {
			Set<Entry<Long, Set<Long>>> entrySet = map.entrySet();
			for (Entry<Long, Set<Long>> entry : entrySet) {
				Set<Long> idSet = entry.getValue();
				for (Long userID : idSet) {
					User user = userDao.getUserByID(userID);
					if (sb.length() == 0) {
						sb.append(user.getName());
					} else {
						sb.append(" " + user.getName());
					}
				}
			}
		}

		return sb.toString();
	}

	private boolean hasRightToFeedback(Problem problem, User user, Long transferID, JobPost post1, JobPost post2, JobPost post3, Role role,
			int processMethod) {
		if (this.isLingDaoBanzi(post1, post2, post3, role)) {
			return true;
		}

		if (processMethod == Constants.PROCESS_METHOD_PROVE) {
			if (user.getDepartment1ID().equals(Constants.DEPARTMENT1_ID_HSEDUCHA)) {
				return true;
			}

			DepartmentDao departmentDao = DaoCreator.createDepartmentDao();
			Department2 depart2 = departmentDao.getDepartment2ByID(user.getDepartment2ID());
			if (depart2.isEquip() && depart2.getEquipID().equals(problem.getEquipmentID())) {
				return true;
			}

			return false;
		}

		return true;
	}

	private boolean hasRightToClose(User closer, User writer, Problem problem) {
		UserAction userAction = ActionCreator.createUserAction();

		Role closerRole = userAction.getUserRole(closer);
		Role writerRole = userAction.getUserRole(writer);

		if (this.isLingDaoBanzi(null, null, null, closerRole)) {
			return true;
		}

		if (problem.getEscalateDepart1ID() == null) {
			if (!closer.getDepartment1ID().equals(writer.getDepartment1ID())) {
				return false;
			}

			if ((closerRole.getRoleType() & (Constants.ROLE_TYPE_CHUZHANG | Constants.ROLE_TYPE_BUZHANG)) > 0) {
				return true;
			}

			if ((closerRole.getRoleType() & (Constants.ROLE_TYPE_KEZHANG | Constants.ROLE_TYPE_FUKEZHANG | Constants.ROLE_TYPE_FUCHUZHANG
					| Constants.ROLE_TYPE_SHENGCHANFUBUZHANG | Constants.ROLE_TYPE_SHEBEIFUBUZHANG | Constants.ROLE_TYPE_ANQUANZONGJIAN
					| Constants.ROLE_TYPE_ZHUANGZHIZHANG | Constants.ROLE_TYPE_ZUZHANG)) > 0) {
				if (closerRole.getRoleLevel() >= writerRole.getRoleLevel()) {
					return true;
				}
			}

			if (closerRole.getRoleType() == Constants.ROLE_TYPE_ZUYUAN
					&& (problem.getProblemType() != null && problem.getProblemType().equals(Constants.PROBLEM_TYPE_WEAK_REPORT))) {
				return true;
			}
		} else {
			if (closerRole.getRoleType() == Constants.ROLE_TYPE_CHUZHANG || closerRole.getRoleType() == Constants.ROLE_TYPE_FUCHUZHANG) {
				return true;
			}
		}

		return false;
	}

	private boolean hasRightToSendback(User sendbacker, Problem problem) {
		UserAction userAction = ActionCreator.createUserAction();
		UserDao userDao = DaoCreator.createUserDao();
		ProblemDao problemDao = DaoCreator.createProblemDao();
		AccidentDao accidentDao = DaoCreator.createAccidentDao();

		Role sendbackerRole = userAction.getUserRole(sendbacker);

		if (this.isLingDaoBanzi(null, null, null, sendbackerRole)) {
			return true;
		}

		Role closerRole = null;
		User closer = null;
		if (problem.getProcessStatus() >= Constants.PROBLEM_STATUS_CLOSE) {
			closer = userDao.getUserByID(problem.getCloseUserID());
			closerRole = userAction.getUserRole(closer);
		}

		Role submitterRole = null;
		User submitter = null;
		if (problem.getProblemType().equals(Constants.PROBLEM_TYPE_DEFECT)) {
			Defect defect = problemDao.getDefectByID(problem.getId());
			submitter = userDao.getUserByID(defect.getDefectWriteUserID());
		} else if (problem.getProblemType().equals(Constants.PROBLEM_TYPE_OTHER)) {
			Other defect = problemDao.getOtherByID(problem.getId());
			submitter = userDao.getUserByID(defect.getDefectWriteUserID());
		} else if (problem.getProblemType().equals(Constants.PROBLEM_TYPE_NOTPLANED_SHUTDOWN)
				|| problem.getProblemType().equals(Constants.PROBLEM_TYPE_TEMP_SHUTDOWN)) {
			Shutdown shutdown = problemDao.getShutdownByID(problem.getId());
			submitter = userDao.getUserByID(shutdown.getShutdownWriteUserID());
		} else if (problem.getProblemType().equals(Constants.PROBLEM_TYPE_TENDENCY)) {
			Tendency tendency = problemDao.getTendencyByID(problem.getId());
			submitter = userDao.getUserByID(tendency.getTendencyWriteUserID());
		} else if (problem.getProblemType().equals(Constants.PROBLEM_TYPE_ACCIDENT_REGISTERFORM)) {
			AccidentRegisterForm registerform = accidentDao.getRegisterFormByID(problem.getId());
			submitter = userDao.getUserByID(registerform.getAccidentWriteUserID());
		} else if (problem.getProblemType().equals(Constants.PROBLEM_TYPE_ACCIDENT_INFOSHEET)) {
			AccidentInfoSheet infosheet = accidentDao.getInfosheetByID(problem.getId());
			submitter = userDao.getUserByID(infosheet.getAccidentWriteUserID());
		} else if (problem.getProblemType().equals(Constants.PROBLEM_TYPE_ACCIDENT_REPORT)) {
			AccidentReport report = accidentDao.getReportByID(problem.getId());
			submitter = userDao.getUserByID(report.getAccidentWriteUserID());
		} else if (problem.getProblemType().equals(Constants.PROBLEM_TYPE_ACCIDENT_CHECKFORM2)) {
			AccidentCheckForm checkform2 = accidentDao.getCheckFormByID(2, problem.getId());
			submitter = userDao.getUserByID(checkform2.getAccidentWriteUserID());
		} else if (problem.getProblemType().equals(Constants.PROBLEM_TYPE_ACCIDENT_CHECKFORM3)) {
			AccidentCheckForm checkform3 = accidentDao.getCheckFormByID(3, problem.getId());
			submitter = userDao.getUserByID(checkform3.getAccidentWriteUserID());
		}

		if (submitter != null) {
			submitterRole = userAction.getUserRole(submitter);
		}

		if (problem.getProblemType() == null || problem.getProblemType().equals(0)
				|| problem.getProblemType().equals(Constants.PROBLEM_TYPE_POSTCHECK)) {
			// process general problem and postcheck

			if (problem.getEscalateDepart1ID() == null) {
				if (problem.getProcessStatus() < Constants.PROBLEM_STATUS_CLOSE) {
					return false;
				}

				if (!sendbacker.getDepartment1ID().equals(closer.getDepartment1ID())) {
					return false;
				}

				if ((sendbackerRole.getRoleType() & (Constants.ROLE_TYPE_CHUZHANG | Constants.ROLE_TYPE_BUZHANG)) > 0) {
					return true;
				}

				if ((sendbackerRole.getRoleType() & (Constants.ROLE_TYPE_FUCHUZHANG | Constants.ROLE_TYPE_SHENGCHANFUBUZHANG
						| Constants.ROLE_TYPE_SHEBEIFUBUZHANG | Constants.ROLE_TYPE_ANQUANZONGJIAN)) > 0
						&& sendbackerRole.getRoleLevel() >= closerRole.getRoleLevel()) {
					return true;
				}
			} else {
				if ((sendbackerRole.getRoleType() & (Constants.ROLE_TYPE_CHUZHANG | Constants.ROLE_TYPE_FUCHUZHANG)) > 0) {
					return true;
				}
			}
		} else {
			// process other problem report

			if (problem.isProcessingByChushi()) {
				if ((sendbackerRole.getRoleType() & (Constants.ROLE_TYPE_CHUZHANG | Constants.ROLE_TYPE_FUCHUZHANG)) > 0) {
					return true;
				}
			} else {
				if (submitter != null && !sendbacker.getDepartment1ID().equals(submitter.getDepartment1ID())) {
					return false;
				}

				if ((sendbackerRole.getRoleType() & (Constants.ROLE_TYPE_CHUZHANG | Constants.ROLE_TYPE_BUZHANG)) > 0) {
					return true;
				}

				if ((sendbackerRole.getRoleType() & (Constants.ROLE_TYPE_FUCHUZHANG | Constants.ROLE_TYPE_SHENGCHANFUBUZHANG
						| Constants.ROLE_TYPE_SHEBEIFUBUZHANG | Constants.ROLE_TYPE_ANQUANZONGJIAN)) > 0
						&& sendbackerRole.getRoleLevel() >= submitterRole.getRoleLevel()) {
					return true;
				}
			}
		}

		return false;
	}

	public boolean isShowShengChanManageGroup(HttpServletRequest request) {
		HttpSession session = request.getSession();

		User user = (User) session.getAttribute(Constants.SESSION_USER);
		Long depart1ID = user.getDepartment1ID();
		String depart1IDStr = request.getParameter(Constants.REQUEST_PARAMETER_DEPARTMENT1ID);
		try {
			depart1ID = new Long(depart1IDStr);
		} catch (Exception e) {
		}

		if ((depart1ID >= Constants.SHIYEBU_ID_HUANJINGJIANCE && depart1ID <= Constants.SHIYEBU_ID_LIANYOUYITIXIANGMU)
				|| depart1ID.equals(Constants.SHIYEBU_ID_CHUYUN1) || depart1ID.equals(Constants.SHIYEBU_ID_HUAGONG1)
				|| depart1ID.equals(Constants.SHIYEBU_ID_HUAGONG2) || depart1ID.equals(Constants.SHIYEBU_ID_HUAGONG3)
				|| depart1ID.equals(Constants.SHIYEBU_ID_HUAGONG4) || depart1ID.equals(Constants.SHIYEBU_ID_LIANYOU1)
				|| depart1ID.equals(Constants.SHIYEBU_ID_LIANYOU2) || depart1ID.equals(Constants.SHIYEBU_ID_LIANYOU3)
				|| depart1ID.equals(Constants.SHIYEBU_ID_LIANYOU4) || depart1ID.equals(Constants.SHIYEBU_ID_LIANYOU5)
				|| depart1ID.equals(Constants.SHIYEBU_ID_SHUIWUGUANLI)) {
			return true;
		}

		return false;
	}

	public boolean isShowShengchanShebeiManageGroup(HttpServletRequest request) {
		HttpSession session = request.getSession();

		User user = (User) session.getAttribute(Constants.SESSION_USER);
		Long depart1ID = user.getDepartment1ID();
		String depart1IDStr = request.getParameter(Constants.REQUEST_PARAMETER_DEPARTMENT1ID);
		try {
			depart1ID = new Long(depart1IDStr);
		} catch (Exception e) {
		}

		if (depart1ID.equals(Constants.SHIYEBU_ID_CHUYUN2)) {
			return true;
		}

		return false;
	}

	public boolean isShowJishuManageGroup(HttpServletRequest request) {
		HttpSession session = request.getSession();

		User user = (User) session.getAttribute(Constants.SESSION_USER);
		Long depart1ID = user.getDepartment1ID();
		String depart1IDStr = request.getParameter(Constants.REQUEST_PARAMETER_DEPARTMENT1ID);
		try {
			depart1ID = new Long(depart1IDStr);
		} catch (Exception e) {
		}

		if (depart1ID.equals(Constants.SHIYEBU_ID_CHANPINFENXIFUWU)) {
			return true;
		}

		return false;
	}

	public boolean isShowKeyanJishuFuwuManageGroup(HttpServletRequest request) {
		HttpSession session = request.getSession();

		User user = (User) session.getAttribute(Constants.SESSION_USER);
		Long depart1ID = user.getDepartment1ID();
		String depart1IDStr = request.getParameter(Constants.REQUEST_PARAMETER_DEPARTMENT1ID);
		try {
			depart1ID = new Long(depart1IDStr);
		} catch (Exception e) {
		}

		if (depart1ID.equals(Constants.SHIYEBU_ID_CHANPINFENXIFUWU)) {
			return true;
		}

		return false;
	}

	public boolean isShowRedianYunxingManageGroup(HttpServletRequest request) {
		HttpSession session = request.getSession();

		User user = (User) session.getAttribute(Constants.SESSION_USER);
		Long depart1ID = user.getDepartment1ID();
		String depart1IDStr = request.getParameter(Constants.REQUEST_PARAMETER_DEPARTMENT1ID);
		try {
			depart1ID = new Long(depart1IDStr);
		} catch (Exception e) {
		}

		if (depart1ID.equals(Constants.SHIYEBU_ID_DONGLIGUANLI)) {
			return true;
		}

		return false;
	}

	public boolean isShowGongyongGongchengManageGroup(HttpServletRequest request) {
		HttpSession session = request.getSession();

		User user = (User) session.getAttribute(Constants.SESSION_USER);
		Long depart1ID = user.getDepartment1ID();
		String depart1IDStr = request.getParameter(Constants.REQUEST_PARAMETER_DEPARTMENT1ID);
		try {
			depart1ID = new Long(depart1IDStr);
		} catch (Exception e) {
		}

		if (depart1ID.equals(Constants.SHIYEBU_ID_DONGLIGUANLI)) {
			return true;
		}

		return false;
	}

	public boolean isShowShebeiManageGroup(HttpServletRequest request) {
		HttpSession session = request.getSession();

		User user = (User) session.getAttribute(Constants.SESSION_USER);
		Long depart1ID = user.getDepartment1ID();
		String depart1IDStr = request.getParameter(Constants.REQUEST_PARAMETER_DEPARTMENT1ID);
		try {
			depart1ID = new Long(depart1IDStr);
		} catch (Exception e) {
		}

		if (depart1ID.equals(Constants.SHIYEBU_ID_CHUYUN2)) {
			return false;
		}

		return true;
	}

	public boolean isShowCangchuManageGroup(HttpServletRequest request) {
		HttpSession session = request.getSession();

		User user = (User) session.getAttribute(Constants.SESSION_USER);
		Long depart1ID = user.getDepartment1ID();
		String depart1IDStr = request.getParameter(Constants.REQUEST_PARAMETER_DEPARTMENT1ID);
		try {
			depart1ID = new Long(depart1IDStr);
		} catch (Exception e) {
		}

		if (depart1ID.equals(Constants.SHIYEBU_ID_CHUYUN2)) {
			return true;
		}

		return false;
	}

	public List<User> getEscalateUserList(HttpServletRequest request) {
		HttpSession session = request.getSession();
		List<User> escalateUsers = new ArrayList<User>();
		User user = (User) session.getAttribute(Constants.SESSION_USER);

		String problemTypeStr = request.getParameter(Constants.REQUEST_PARAMETER_PROBLEM_TYPE);
		int problemType = -1;
		try {
			problemType = Integer.parseInt(problemTypeStr);
		} catch (Exception e) {
		}

		UserDao userDao = DaoCreator.createUserDao();
		TitlePostManageGroupDao tpmDao = DaoCreator.createTitlePostManageGroupDao();
		DepartmentDao departDao = DaoCreator.createDepartmentDao();

		Department3 department3 = departDao.getDepartment3ByID(user.getDepartment3ID());
		Role role = tpmDao.getRoleByID(department3.getRoleID());

		if (problemType == -1) {
			if ((role.getRoleType() & (Constants.ROLE_TYPE_ZUZHANG | Constants.ROLE_TYPE_ZHUANGZHIZHANG)) > 0) {
				List<User> users1 = userDao.getUsersByRoleType(user.getDepartment1ID(), Constants.ROLE_TYPE_ANQUANZONGJIAN);
				List<User> users2 = userDao.getUsersByRoleType(user.getDepartment1ID(), Constants.ROLE_TYPE_SHEBEIFUBUZHANG);
				List<User> users3 = userDao.getUsersByRoleType(user.getDepartment1ID(), Constants.ROLE_TYPE_SHENGCHANFUBUZHANG);

				escalateUsers.addAll(users1);
				escalateUsers.addAll(users2);
				escalateUsers.addAll(users3);
			} else if ((role.getRoleType() & (Constants.ROLE_TYPE_ANQUANZONGJIAN | Constants.ROLE_TYPE_SHEBEIFUBUZHANG | Constants.ROLE_TYPE_SHENGCHANFUBUZHANG)) > 0) {
				List<User> users = userDao.getUsersByRoleType(user.getDepartment1ID(), Constants.ROLE_TYPE_BUZHANG);

				escalateUsers.addAll(users);
			} else if ((role.getRoleType() & (Constants.ROLE_TYPE_KEZHANG | Constants.ROLE_TYPE_FUKEZHANG)) > 0) {
				List<User> users = userDao.getUsersByRoleType(user.getDepartment1ID(), Constants.ROLE_TYPE_FUCHUZHANG
						| Constants.ROLE_TYPE_CHUZHANG);

				escalateUsers.addAll(users);
			} else if ((role.getRoleType() & Constants.ROLE_TYPE_FUCHUZHANG) > 0) {
				List<User> users = userDao.getUsersByRoleType(user.getDepartment1ID(), Constants.ROLE_TYPE_CHUZHANG);

				escalateUsers.addAll(users);
			}
		} else if (problemType == Constants.PROBLEM_TYPE_POSTCHECK_MONTH_CHECK_REPORT
				|| problemType == Constants.PROBLEM_TYPE_POSTCHECK_MONTH_SANWEI_REPORT
				|| problemType == Constants.PROBLEM_TYPE_POSTCHECK_MONTH_CORPSANWEI_REPORT) {
			if ((role.getRoleType() & (Constants.ROLE_TYPE_YIXIANYUANGONG | Constants.ROLE_TYPE_ZUYUAN | Constants.ROLE_TYPE_ZUZHANG
					| Constants.ROLE_TYPE_ZHUANGZHIZHANG | Constants.ROLE_TYPE_ANQUANZONGJIAN | Constants.ROLE_TYPE_SHENGCHANFUBUZHANG
					| Constants.ROLE_TYPE_SHEBEIFUBUZHANG | Constants.ROLE_TYPE_BUZHANG)) > 0) {
				List<User> users1 = userDao.getUsersByRoleType(user.getDepartment1ID(), Constants.ROLE_TYPE_ANQUANZONGJIAN);
				List<User> users2 = userDao.getUsersByRoleType(user.getDepartment1ID(), Constants.ROLE_TYPE_SHEBEIFUBUZHANG);
				List<User> users3 = userDao.getUsersByRoleType(user.getDepartment1ID(), Constants.ROLE_TYPE_SHENGCHANFUBUZHANG);
				List<User> users4 = userDao.getUsersByRoleType(user.getDepartment1ID(), Constants.ROLE_TYPE_BUZHANG);

				escalateUsers.addAll(users1);
				escalateUsers.addAll(users2);
				escalateUsers.addAll(users3);
				escalateUsers.addAll(users4);
			} else if ((role.getRoleType() & (Constants.ROLE_TYPE_KEYUAN | Constants.ROLE_TYPE_FUKEZHANG | Constants.ROLE_TYPE_KEZHANG
					| Constants.ROLE_TYPE_FUCHUZHANG | Constants.ROLE_TYPE_CHUZHANG)) > 0) {
				List<User> users1 = userDao.getUsersByRoleType(user.getDepartment1ID(), Constants.ROLE_TYPE_FUCHUZHANG);
				List<User> users2 = userDao.getUsersByRoleType(user.getDepartment1ID(), Constants.ROLE_TYPE_CHUZHANG);
				escalateUsers.addAll(users1);
				escalateUsers.addAll(users2);

				if (escalateUsers.isEmpty()) {
					List<User> users3 = userDao.getUsersByRoleType(user.getDepartment1ID(), Constants.ROLE_TYPE_FUKEZHANG);
					List<User> users4 = userDao.getUsersByRoleType(user.getDepartment1ID(), Constants.ROLE_TYPE_KEZHANG);

					escalateUsers.addAll(users3);
					escalateUsers.addAll(users4);
				}
			}
		} else if (problemType == Constants.PROBLEM_TYPE_WEAK_REPORT) {
			int weakReportType = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_WEAK_REPORT_TYPE, 0);
			if (weakReportType == Constants.WEAK_REPORT_TYPE_YIXIANYUANGONG) {
				Long equipID = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_EQUIP_ID, (Long) null);
				EquipmentDao equipDao = DaoCreator.createEquipmentDao();
				List<User> zhuangzhizhangList = equipDao.getEquipmentZhuangzhizhang(equipID);
				List<User> zhuangzhizhangList2 = equipDao.getEquipmentMappingUser(equipID, Constants.DEPARTMENT_TYPE_SHIYEBU);
				zhuangzhizhangList.addAll(zhuangzhizhangList2);
				escalateUsers.addAll(zhuangzhizhangList);
			} else {
				if ((role.getRoleType() & (Constants.ROLE_TYPE_YIXIANYUANGONG | Constants.ROLE_TYPE_ZUYUAN | Constants.ROLE_TYPE_ZUZHANG
						| Constants.ROLE_TYPE_ZHUANGZHIZHANG | Constants.ROLE_TYPE_ANQUANZONGJIAN | Constants.ROLE_TYPE_SHENGCHANFUBUZHANG
						| Constants.ROLE_TYPE_SHEBEIFUBUZHANG | Constants.ROLE_TYPE_BUZHANG)) > 0) {
					List<User> users1 = userDao.getUsersByRoleType(user.getDepartment1ID(), Constants.ROLE_TYPE_ANQUANZONGJIAN);
					List<User> users2 = userDao.getUsersByRoleType(user.getDepartment1ID(), Constants.ROLE_TYPE_SHEBEIFUBUZHANG);
					List<User> users3 = userDao.getUsersByRoleType(user.getDepartment1ID(), Constants.ROLE_TYPE_SHENGCHANFUBUZHANG);
					List<User> users4 = userDao.getUsersByRoleType(user.getDepartment1ID(), Constants.ROLE_TYPE_BUZHANG);

					escalateUsers.addAll(users1);
					escalateUsers.addAll(users2);
					escalateUsers.addAll(users3);
					escalateUsers.addAll(users4);
				} else if ((role.getRoleType() & (Constants.ROLE_TYPE_KEYUAN | Constants.ROLE_TYPE_FUKEZHANG | Constants.ROLE_TYPE_KEZHANG
						| Constants.ROLE_TYPE_FUCHUZHANG | Constants.ROLE_TYPE_CHUZHANG)) > 0) {
					List<User> users1 = userDao.getUsersByRoleType(user.getDepartment1ID(), Constants.ROLE_TYPE_FUCHUZHANG);
					List<User> users2 = userDao.getUsersByRoleType(user.getDepartment1ID(), Constants.ROLE_TYPE_CHUZHANG);
					escalateUsers.addAll(users1);
					escalateUsers.addAll(users2);

					if (escalateUsers.isEmpty()) {
						List<User> users3 = userDao.getUsersByRoleType(user.getDepartment1ID(), Constants.ROLE_TYPE_FUKEZHANG);
						List<User> users4 = userDao.getUsersByRoleType(user.getDepartment1ID(), Constants.ROLE_TYPE_KEZHANG);

						escalateUsers.addAll(users3);
						escalateUsers.addAll(users4);
					}
				}
			}
		}

		return escalateUsers;
	}

	public boolean chooseEscalateUser(HttpServletRequest request) {
		String idStr = request.getParameter(Constants.REQUEST_PARAMETER_ID);
		Long id = 0L;
		try {
			id = new Long(idStr);
		} catch (Exception e) {
		}

		HttpSession session = request.getSession();

		UserDao userDao = DaoCreator.createUserDao();
		User user = userDao.getUserByID(id);

		session.setAttribute(Constants.SESSION_ESCALATE_USER, user);

		return true;
	}

	public boolean showYiZhengGaiButton(JobPost post1, JobPost post2, JobPost post3, Role role) {
		if (this.isLingDaoBanzi(post1, post2, post3, role)) {
			return true;
		}

		int intRole = this.calRole(post1, post2, post3, role);

		if ((intRole & (Constants.ROLE_TYPE_ZUYUAN | Constants.ROLE_TYPE_KEYUAN | Constants.ROLE_TYPE_YIXIANYUANGONG)) > 0) {
			return false;
		}

		return true;
	}

	public boolean showFeedbackButton(JobPost post1, JobPost post2, JobPost post3, Role role) {
		return false;
	}

	public boolean showYanzhengButton(JobPost post1, JobPost post2, JobPost post3, Role role, User user, Problem problem) {
		int intRole = this.calRole(post1, post2, post3, role);

		if ((intRole & (Constants.ROLE_TYPE_YIXIANYUANGONG)) > 0) {
			DepartmentDao departmentDao = DaoCreator.createDepartmentDao();
			Department2 depart2 = departmentDao.getDepartment2ByID(user.getDepartment2ID());
			if (depart2.isEquip() && depart2.getEquipID().equals(problem.getEquipmentID())) {
				return true;
			}
		}

		if (user.getDepartment1ID().equals(Constants.DEPARTMENT1_ID_HSEDUCHA)) {
			return true;
		}

		return false;
	}

	public boolean showTuihuiButton(JobPost post1, JobPost post2, JobPost post3, Role role) {
		if (this.isLingDaoBanzi(post1, post2, post3, role)) {
			return true;
		}

		int intRole = this.calRole(post1, post2, post3, role);

		if ((intRole & Constants.ROLE_TYPE_ANQUANZONGJIAN) > 0 || (intRole & Constants.ROLE_TYPE_SHEBEIFUBUZHANG) > 0
				|| (intRole & Constants.ROLE_TYPE_SHENGCHANFUBUZHANG) > 0 || (intRole & Constants.ROLE_TYPE_FUCHUZHANG) > 0
				|| (intRole & Constants.ROLE_TYPE_CHUZHANG) > 0 || (intRole & Constants.ROLE_TYPE_BUZHANG) > 0) {
			return true;
		}

		return false;
	}

	public boolean showXiangGuanChuShiButton(JobPost post1, JobPost post2, JobPost post3, Role role) {
		if (this.isLingDaoBanzi(post1, post2, post3, role)) {
			return true;
		}

		int intRole = this.calRole(post1, post2, post3, role);

		if ((intRole & Constants.ROLE_TYPE_FUKEZHANG) > 0 || (intRole & Constants.ROLE_TYPE_FUCHUZHANG) > 0
				|| (intRole & Constants.ROLE_TYPE_KEZHANG) > 0 || (intRole & Constants.ROLE_TYPE_CHUZHANG) > 0) {
			return true;
		}

		return false;
	}

	public boolean showShangBaoZhiNengChuShiButton(JobPost post1, JobPost post2, JobPost post3, Role role) {
		int intRole = this.calRole(post1, post2, post3, role);

		if ((intRole & Constants.ROLE_TYPE_ZHUANGZHIZHANG) > 0 || (intRole & Constants.ROLE_TYPE_ZUZHANG) > 0
				|| (intRole & Constants.ROLE_TYPE_SHEBEIFUBUZHANG) > 0 || (intRole & Constants.ROLE_TYPE_SHENGCHANFUBUZHANG) > 0
				|| (intRole & Constants.ROLE_TYPE_BUZHANG) > 0 || (intRole & Constants.ROLE_TYPE_ANQUANZONGJIAN) > 0) {
			return true;
		}

		return false;
	}

	public boolean showZhuanJiaoTaoRenButton(JobPost post1, JobPost post2, JobPost post3, Role role, User user, Problem problem) {
		int intRole = this.calRole(post1, post2, post3, role);

		if ((intRole & (Constants.ROLE_TYPE_ZHUANGZHIZHANG | Constants.ROLE_TYPE_BUZHANG | Constants.ROLE_TYPE_SHEBEIFUBUZHANG
				| Constants.ROLE_TYPE_SHENGCHANFUBUZHANG | Constants.ROLE_TYPE_FUCHUZHANG | Constants.ROLE_TYPE_CHUZHANG
				| Constants.ROLE_TYPE_ANQUANZONGJIAN | Constants.ROLE_TYPE_ZUZHANG | Constants.ROLE_TYPE_KEZHANG | Constants.ROLE_TYPE_FUKEZHANG)) > 0) {
			return true;
		}

		return false;
	}

	public int calRole(JobPost post1, JobPost post2, JobPost post3, Role role) {
		int intRole = 0;

		return intRole | role.getRoleType();
	}

	public List<ManageGroup> getWriterManageGroupList(HttpServletRequest request) {
		HttpSession session = request.getSession();

		User user = (User) session.getAttribute(Constants.SESSION_USER);
		List<ManageGroup> groupList = new ArrayList<ManageGroup>();
		TitlePostManageGroupDao tpmDao = DaoCreator.createTitlePostManageGroupDao();

		if (user == null) {
			user = (User) session.getAttribute(Constants.SESSION_REGISTER_USER);
		}
		Long depart1ID = user.getDepartment1ID();
		String depart1IDStr = request.getParameter(Constants.REQUEST_PARAMETER_DEPARTMENT1ID);
		try {
			depart1ID = new Long(depart1IDStr);
		} catch (Exception e) {
		}

		if (depart1ID.equals(Constants.SHIYEBU_ID_LIANYOU1) || depart1ID.equals(Constants.SHIYEBU_ID_LIANYOU2)
				|| depart1ID.equals(Constants.SHIYEBU_ID_LIANYOU3) || depart1ID.equals(Constants.SHIYEBU_ID_LIANYOU4)
				|| depart1ID.equals(Constants.SHIYEBU_ID_LIANYOU5) || depart1ID.equals(Constants.SHIYEBU_ID_HUAGONG1)
				|| depart1ID.equals(Constants.SHIYEBU_ID_HUAGONG2) || depart1ID.equals(Constants.SHIYEBU_ID_HUAGONG3)
				|| depart1ID.equals(Constants.SHIYEBU_ID_HUAGONG4) || depart1ID.equals(Constants.SHIYEBU_ID_CHUYUN1)
				|| depart1ID.equals(Constants.SHIYEBU_ID_SHUIWUGUANLI)) {
			groupList.add(tpmDao.getManageGroupByID(Constants.MANAGE_GROUP_ID_SHENGCHAN));
			groupList.add(tpmDao.getManageGroupByID(Constants.MANAGE_GROUP_ID_SHEBEI));
			groupList.add(tpmDao.getManageGroupByID(Constants.MANAGE_GROUP_ID_HSE));
			groupList.add(tpmDao.getManageGroupByID(Constants.MANAGE_GROUP_ID_ZONGHE));
			groupList.add(tpmDao.getManageGroupByID(Constants.MANAGE_GROUP_ID_DANGQUN));
		} else if (depart1ID.equals(Constants.SHIYEBU_ID_CHUYUN2)) {
			groupList.add(tpmDao.getManageGroupByID(Constants.MANAGE_GROUP_ID_SHENGCHANSHEBEI));
			groupList.add(tpmDao.getManageGroupByID(Constants.MANAGE_GROUP_ID_CANGCHU));
			groupList.add(tpmDao.getManageGroupByID(Constants.MANAGE_GROUP_ID_HSE));
			groupList.add(tpmDao.getManageGroupByID(Constants.MANAGE_GROUP_ID_ZONGHE));
			groupList.add(tpmDao.getManageGroupByID(Constants.MANAGE_GROUP_ID_DANGQUN));
		} else if (depart1ID.equals(Constants.SHIYEBU_ID_CHANPINFENXIFUWU)) {
			groupList.add(tpmDao.getManageGroupByID(Constants.MANAGE_GROUP_ID_JISHU));
			groupList.add(tpmDao.getManageGroupByID(Constants.MANAGE_GROUP_ID_SHEBEI));
			groupList.add(tpmDao.getManageGroupByID(Constants.MANAGE_GROUP_ID_HSE));
			groupList.add(tpmDao.getManageGroupByID(Constants.MANAGE_GROUP_ID_ZONGHE));
			groupList.add(tpmDao.getManageGroupByID(Constants.MANAGE_GROUP_ID_DANGQUN));
			groupList.add(tpmDao.getManageGroupByID(Constants.MANAGE_GROUP_ID_KEYAN_JISHU_FUWU));
		} else if (depart1ID.equals(Constants.SHIYEBU_ID_DONGLIGUANLI)) {
			groupList.add(tpmDao.getManageGroupByID(Constants.MANAGE_GROUP_ID_REDIANYUNXING));
			groupList.add(tpmDao.getManageGroupByID(Constants.MANAGE_GROUP_ID_GONGYONGGONGCHENG));
			groupList.add(tpmDao.getManageGroupByID(Constants.MANAGE_GROUP_ID_SHEBEI));
			groupList.add(tpmDao.getManageGroupByID(Constants.MANAGE_GROUP_ID_HSE));
			groupList.add(tpmDao.getManageGroupByID(Constants.MANAGE_GROUP_ID_ZONGHE));
			groupList.add(tpmDao.getManageGroupByID(Constants.MANAGE_GROUP_ID_DANGQUN));
		}

		return groupList;
	}

	public List<User> getManageGroupMappingUserList(HttpServletRequest request, Long manageGroupID) {
		HttpSession session = request.getSession();

		Long depart1ID = null;
		Department1 problemDepart1 = (Department1) session.getAttribute(Constants.SESSION_PROBLEM_DEPARTMENT1);
		User theUser = (User) session.getAttribute(Constants.SESSION_USER);

		if (problemDepart1 != null) {
			depart1ID = problemDepart1.getId();
		} else {
			if (theUser != null) {
				depart1ID = theUser.getDepartment1ID();
			}
		}

		String depart1IDStr = request.getParameter(Constants.REQUEST_PARAMETER_DEPARTMENT1ID);
		try {
			depart1ID = new Long(depart1IDStr);
		} catch (Exception e) {
		}

		UserDao userDao = DaoCreator.createUserDao();
		List<User> userList = userDao.getManageGroupMappingUserList(manageGroupID, depart1ID);

		return userList;
	}

	public boolean isLingDaoBanzi(JobPost post1, JobPost post2, JobPost post3, Role role) {
		int intRole = this.calRole(post1, post2, post3, role);

		if ((intRole & (Constants.ROLE_TYPE_ZONGSHI | Constants.ROLE_TYPE_FUZONGJINGLI | Constants.ROLE_TYPE_ZONGJINGLI)) > 0) {
			return true;
		}

		return false;
	}

	public boolean convertDefect(HttpServletRequest request) {
		String transferIDStr = request.getParameter(Constants.REQUEST_PARAMETER_TRANSFER_ID);
		String problemIDStr = request.getParameter(Constants.REQUEST_PARAMETER_ID);
		String defectTypeIDStr = request.getParameter(Constants.REQUEST_PARAMETER_DEFECT_TYPE_ID);
		String problemTitle = request.getParameter(Constants.REQUEST_PARAMETER_PROBLEM_TITLE);
		String writeDateStr = request.getParameter(Constants.REQUEST_PARAMETER_WRITE_DATE);
		String problemContent = request.getParameter(Constants.REQUEST_PARAMETER_PROBLEM_CONTENT);
		String loss = request.getParameter(Constants.REQUEST_PARAMETER_LOSS);
		String reason = request.getParameter(Constants.REQUEST_PARAMETER_REASON);
		String zhenggaiCuoshi = request.getParameter(Constants.REQUEST_PARAMETER_ZHENGGAI_CUOSHI);
		String duty = request.getParameter(Constants.REQUEST_PARAMETER_DUTY);
		String team = request.getParameter(Constants.REQUEST_PARAMETER_TEAM);

		Long transferID = null;
		Long problemID = 0l;
		Integer defectTypeID = 0;
		Calendar writeDate = null;

		try {
			problemID = new Long(problemIDStr);
		} catch (Exception e) {
		}

		try {
			transferID = new Long(transferIDStr);
		} catch (Exception e) {
		}

		try {
			defectTypeID = new Integer(defectTypeIDStr);
		} catch (Exception e) {
		}

		try {
			writeDate = Util.convertStrToDate(writeDateStr);
		} catch (Exception e) {
		}

		if (!Util.isNullOrEmpty(problemTitle)) {
			problemTitle = Util.isoToUTF8(problemTitle);
		}

		if (!Util.isNullOrEmpty(problemContent)) {
			problemContent = Util.isoToUTF8(problemContent);
		}

		if (!Util.isNullOrEmpty(zhenggaiCuoshi)) {
			zhenggaiCuoshi = Util.isoToUTF8(zhenggaiCuoshi);
		}
		if (!Util.isNullOrEmpty(reason)) {
			reason = Util.isoToUTF8(reason);
		}

		if (!Util.isNullOrEmpty(loss)) {
			loss = Util.isoToUTF8(loss);
		}

		if (!Util.isNullOrEmpty(duty)) {
			duty = Util.isoToUTF8(duty);
		}

		if (!Util.isNullOrEmpty(team)) {
			team = Util.isoToUTF8(team);
		}

		ProblemDao problemDao = DaoCreator.createProblemDao();
		if (transferID == null) {
			this.createProblemTransfer(request, problemID);
		}

		boolean isSuccess = this.feedbackProblem(request);

		if (isSuccess) {
			User sessionUser = (User) request.getSession().getAttribute(Constants.SESSION_USER);
			isSuccess = problemDao.convertDefect(problemID, defectTypeID, writeDate, problemTitle, problemContent, loss, reason,
					zhenggaiCuoshi, duty, team, sessionUser.getId());
		}

		return isSuccess;
	}

	public boolean convertDefectByCopy(HttpServletRequest request) {
		String problemIDStr = request.getParameter(Constants.REQUEST_PARAMETER_ID);
		String defectTypeIDStr = request.getParameter(Constants.REQUEST_PARAMETER_DEFECT_TYPE_ID);
		String problemTitle = request.getParameter(Constants.REQUEST_PARAMETER_PROBLEM_TITLE);
		String writeDateStr = request.getParameter(Constants.REQUEST_PARAMETER_WRITE_DATE);
		String problemContent = request.getParameter(Constants.REQUEST_PARAMETER_PROBLEM_CONTENT);
		String loss = request.getParameter(Constants.REQUEST_PARAMETER_LOSS);
		String reason = request.getParameter(Constants.REQUEST_PARAMETER_REASON);
		String zhenggaiCuoshi = request.getParameter(Constants.REQUEST_PARAMETER_ZHENGGAI_CUOSHI);
		String duty = request.getParameter(Constants.REQUEST_PARAMETER_DUTY);
		String team = request.getParameter(Constants.REQUEST_PARAMETER_TEAM);

		Long problemID = 0l;
		Integer defectTypeID = 0;
		Calendar writeDate = null;

		try {
			problemID = new Long(problemIDStr);
		} catch (Exception e) {
		}

		try {
			defectTypeID = new Integer(defectTypeIDStr);
		} catch (Exception e) {
		}

		try {
			writeDate = Util.convertStrToDate(writeDateStr);
		} catch (Exception e) {
		}

		if (!Util.isNullOrEmpty(problemTitle)) {
			problemTitle = Util.isoToUTF8(problemTitle);
		}

		if (!Util.isNullOrEmpty(problemContent)) {
			problemContent = Util.isoToUTF8(problemContent);
		}

		if (!Util.isNullOrEmpty(zhenggaiCuoshi)) {
			zhenggaiCuoshi = Util.isoToUTF8(zhenggaiCuoshi);
		}
		if (!Util.isNullOrEmpty(reason)) {
			reason = Util.isoToUTF8(reason);
		}

		if (!Util.isNullOrEmpty(loss)) {
			loss = Util.isoToUTF8(loss);
		}

		if (!Util.isNullOrEmpty(duty)) {
			duty = Util.isoToUTF8(duty);
		}

		if (!Util.isNullOrEmpty(team)) {
			team = Util.isoToUTF8(team);
		}

		ProblemDao problemDao = DaoCreator.createProblemDao();
		Problem problem = problemDao.getProblemByID(problemID);

		problem.setWriteTime(Calendar.getInstance());
		boolean isSuccess = problemDao.addProblem(problem);
		if (!isSuccess) {
			request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_CONVERT_FAIL);
			return false;
		}

		// Change problemID
		problemID = problem.getId();

		isSuccess = this.createProblemTransfer(request, problemID);
		if (!isSuccess) {
			request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_CONVERT_FAIL);
			return false;
		}

		User sessionUser = (User) request.getSession().getAttribute(Constants.SESSION_USER);
		ProblemTransfer transfer = problemDao.getProblemTransfer(sessionUser.getId(), problemID, sessionUser.getId());
		isSuccess = this.feedbackProblem(request, String.valueOf(problemID), String.valueOf(transfer.getId()));
		if (!isSuccess) {
			problemDao.deleteProblemByIDList(new Long[] { problemID });
			// Feedback already set error information.
			return false;
		}

		isSuccess = problemDao.convertDefect(problemID, defectTypeID, writeDate, problemTitle, problemContent, loss, reason,
				zhenggaiCuoshi, duty, team, sessionUser.getId());
		if (!isSuccess) {
			request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_CONVERT_FAIL);
			return false;
		}
		return isSuccess;
	}

	public boolean convertShutdown(HttpServletRequest request) {
		int[] currentTime = Util.getCurrentDate();
		String transferIDStr = request.getParameter(Constants.REQUEST_PARAMETER_TRANSFER_ID);
		String problemIDStr = request.getParameter(Constants.REQUEST_PARAMETER_ID);
		String shutdownTypeIDStr = request.getParameter(Constants.REQUEST_PARAMETER_SHUTDOWN_TYPE_ID);
		String problemTitle = request.getParameter(Constants.REQUEST_PARAMETER_PROBLEM_TITLE);
		String problemContent = request.getParameter(Constants.REQUEST_PARAMETER_PROBLEM_CONTENT);
		String loss = request.getParameter(Constants.REQUEST_PARAMETER_LOSS);
		String reason = request.getParameter(Constants.REQUEST_PARAMETER_REASON);
		String zhenggaiCuoshi = request.getParameter(Constants.REQUEST_PARAMETER_ZHENGGAI_CUOSHI);
		String duty = request.getParameter(Constants.REQUEST_PARAMETER_DUTY);
		String team = request.getParameter(Constants.REQUEST_PARAMETER_TEAM);
		Integer problemType = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_PROBLEM_TYPE, (Integer) null);

		Integer startYear = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_YEAR, currentTime[0]);
		Integer startMonth = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_MONTH, currentTime[1]);
		Integer startDay = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_DAY, currentTime[2]);
		Integer startHour = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_HOUR, currentTime[3]);
		Integer startMinute = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_MINUTE, currentTime[4]);

		Integer endYear = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_END_YEAR, currentTime[0]);
		Integer endMonth = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_END_MONTH, currentTime[1]);
		Integer endDay = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_END_DAY, currentTime[2]);
		Integer endHour = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_END_HOUR, currentTime[3]);
		Integer endMinute = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_END_MINUTE, currentTime[4]);

		Long transferID = null;
		Long problemID = 0l;
		Integer shutdownTypeID = 0;
		Calendar periodStart = Util.getCalendar(new int[] { startYear, startMonth, startDay, startHour, startMinute, 0 });
		Calendar periodEnd = Util.getCalendar(new int[] { endYear, endMonth, endDay, endHour, endMinute, 0 });

		try {
			problemID = new Long(problemIDStr);
		} catch (Exception e) {
		}

		try {
			transferID = new Long(transferIDStr);
		} catch (Exception e) {
		}

		try {
			shutdownTypeID = new Integer(shutdownTypeIDStr);
		} catch (Exception e) {
		}

		if (!Util.isNullOrEmpty(problemTitle)) {
			problemTitle = Util.isoToUTF8(problemTitle);
		}

		if (!Util.isNullOrEmpty(problemContent)) {
			problemContent = Util.isoToUTF8(problemContent);
		}

		if (!Util.isNullOrEmpty(zhenggaiCuoshi)) {
			zhenggaiCuoshi = Util.isoToUTF8(zhenggaiCuoshi);
		}
		if (!Util.isNullOrEmpty(reason)) {
			reason = Util.isoToUTF8(reason);
		}

		if (!Util.isNullOrEmpty(loss)) {
			loss = Util.isoToUTF8(loss);
		}

		if (!Util.isNullOrEmpty(duty)) {
			duty = Util.isoToUTF8(duty);
		}

		if (!Util.isNullOrEmpty(team)) {
			team = Util.isoToUTF8(team);
		}

		ProblemDao problemDao = DaoCreator.createProblemDao();
		if (transferID == null) {
			this.createProblemTransfer(request, problemID);
		}

		boolean isSuccess = this.feedbackProblem(request);

		if (isSuccess) {
			User sessionUser = (User) request.getSession().getAttribute(Constants.SESSION_USER);
			isSuccess = problemDao.convertShutdown(problemID, problemType, shutdownTypeID, problemTitle, problemContent, loss, reason,
					zhenggaiCuoshi, duty, team, periodStart, periodEnd, sessionUser.getId(), null);
		}

		return isSuccess;
	}

	public boolean convertShutdownByCopy(HttpServletRequest request) {
		int[] currentTime = Util.getCurrentDate();
		String problemIDStr = request.getParameter(Constants.REQUEST_PARAMETER_ID);
		String shutdownTypeIDStr = request.getParameter(Constants.REQUEST_PARAMETER_SHUTDOWN_TYPE_ID);
		String problemTitle = request.getParameter(Constants.REQUEST_PARAMETER_PROBLEM_TITLE);
		String problemContent = request.getParameter(Constants.REQUEST_PARAMETER_PROBLEM_CONTENT);
		String loss = request.getParameter(Constants.REQUEST_PARAMETER_LOSS);
		String reason = request.getParameter(Constants.REQUEST_PARAMETER_REASON);
		String zhenggaiCuoshi = request.getParameter(Constants.REQUEST_PARAMETER_ZHENGGAI_CUOSHI);
		String duty = request.getParameter(Constants.REQUEST_PARAMETER_DUTY);
		String team = request.getParameter(Constants.REQUEST_PARAMETER_TEAM);
		Integer problemType = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_PROBLEM_TYPE, (Integer) null);

		Integer startYear = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_YEAR, currentTime[0]);
		Integer startMonth = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_MONTH, currentTime[1]);
		Integer startDay = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_DAY, currentTime[2]);
		Integer startHour = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_HOUR, currentTime[3]);
		Integer startMinute = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_MINUTE, currentTime[4]);

		Integer endYear = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_END_YEAR, currentTime[0]);
		Integer endMonth = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_END_MONTH, currentTime[1]);
		Integer endDay = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_END_DAY, currentTime[2]);
		Integer endHour = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_END_HOUR, currentTime[3]);
		Integer endMinute = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_END_MINUTE, currentTime[4]);

		Boolean escalateZongbu = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_ESCALATE_ZONGBU, (Boolean) null);

		Long problemID = 0l;
		Integer shutdownTypeID = 0;
		Calendar periodStart = Util.getCalendar(new int[] { startYear, startMonth, startDay, startHour, startMinute, 0 });
		Calendar periodEnd = Util.getCalendar(new int[] { endYear, endMonth, endDay, endHour, endMinute, 0 });

		try {
			problemID = new Long(problemIDStr);
		} catch (Exception e) {
		}

		try {
			shutdownTypeID = new Integer(shutdownTypeIDStr);
		} catch (Exception e) {
		}

		if (!Util.isNullOrEmpty(problemTitle)) {
			problemTitle = Util.isoToUTF8(problemTitle);
		}

		if (!Util.isNullOrEmpty(problemContent)) {
			problemContent = Util.isoToUTF8(problemContent);
		}

		if (!Util.isNullOrEmpty(zhenggaiCuoshi)) {
			zhenggaiCuoshi = Util.isoToUTF8(zhenggaiCuoshi);
		}
		if (!Util.isNullOrEmpty(reason)) {
			reason = Util.isoToUTF8(reason);
		}

		if (!Util.isNullOrEmpty(loss)) {
			loss = Util.isoToUTF8(loss);
		}

		if (!Util.isNullOrEmpty(duty)) {
			duty = Util.isoToUTF8(duty);
		}

		if (!Util.isNullOrEmpty(team)) {
			team = Util.isoToUTF8(team);
		}

		if (problemType == Constants.PROBLEM_TYPE_NOTPLANED_SHUTDOWN && escalateZongbu == null) {
			escalateZongbu = Boolean.FALSE;
		}

		ProblemDao problemDao = DaoCreator.createProblemDao();
		Problem problem = problemDao.getProblemByID(problemID);

		problem.setWriteTime(Calendar.getInstance());

		boolean isSuccess = problemDao.addProblem(problem);
		if (!isSuccess) {
			request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_CONVERT_FAIL);
			return false;
		}

		// Change problemID
		problemID = problem.getId();

		isSuccess = this.createProblemTransfer(request, problemID);
		if (!isSuccess) {
			request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_CONVERT_FAIL);
			return false;
		}

		User sessionUser = (User) request.getSession().getAttribute(Constants.SESSION_USER);
		ProblemTransfer transfer = problemDao.getProblemTransfer(sessionUser.getId(), problemID, sessionUser.getId());
		isSuccess = this.feedbackProblem(request, String.valueOf(problemID), String.valueOf(transfer.getId()));
		if (!isSuccess) {
			problemDao.deleteProblemByIDList(new Long[] { problemID });
			// Feedback already set error information.
			return false;
		}

		isSuccess = problemDao.convertShutdown(problemID, problemType, shutdownTypeID, problemTitle, problemContent, loss, reason,
				zhenggaiCuoshi, duty, team, periodStart, periodEnd, sessionUser.getId(), escalateZongbu);
		if (!isSuccess) {
			request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_CONVERT_FAIL);
			return false;
		}
		return isSuccess;
	}

	public boolean createProblemTransfer(HttpServletRequest request, Long problemID) {
		ProblemDao problemDao = DaoCreator.createProblemDao();
		HttpSession session = request.getSession();
		User user = (User) session.getAttribute(Constants.SESSION_USER);

		ProblemTransfer latestTransfer = getLatestTransfer(problemID);

		List<ProblemTransfer> transferList = new ArrayList<ProblemTransfer>(1);
		ProblemTransfer transfer = new ProblemTransfer();

		if (latestTransfer != null) {
			transfer.setUserID(latestTransfer.getUserID());
		} else {
			transfer.setUserID(user.getId());
		}
		transfer.setTransferedUserID(user.getId());
		transfer.setProcessed(false);
		transfer.setProblemID(problemID);
		transfer.setMainTransferUser(true);

		transferList.add(transfer);

		boolean isSuccess = problemDao.addProblemTransfers(transferList);

		return isSuccess;
	}

	private ProblemTransfer getLatestTransfer(Long problemID) {
		ProblemDao problemDao = DaoCreator.createProblemDao();

		ProblemTransfer latestTransfer = null;
		Long max = 0l;
		List<ProblemTransfer> transferLst = problemDao.getProblemTransferByProblemID(problemID);
		for (ProblemTransfer transfer : transferLst) {
			if (transfer.getId() > max) {
				max = transfer.getId();
				latestTransfer = transfer;
			}
		}

		return latestTransfer;
	}

	public boolean convertTendency(HttpServletRequest request) {
		String transferIDStr = request.getParameter(Constants.REQUEST_PARAMETER_TRANSFER_ID);
		String problemIDStr = request.getParameter(Constants.REQUEST_PARAMETER_ID);
		String tendencyTypeIDStr = request.getParameter(Constants.REQUEST_PARAMETER_TENDENCY_TYPE_ID);
		String problemTitle = request.getParameter(Constants.REQUEST_PARAMETER_PROBLEM_TITLE);
		String writeDateStr = request.getParameter(Constants.REQUEST_PARAMETER_WRITE_DATE);
		String problemContent = request.getParameter(Constants.REQUEST_PARAMETER_PROBLEM_CONTENT);
		String loss = request.getParameter(Constants.REQUEST_PARAMETER_LOSS);
		String reason = request.getParameter(Constants.REQUEST_PARAMETER_REASON);
		String zhenggaiCuoshi = request.getParameter(Constants.REQUEST_PARAMETER_ZHENGGAI_CUOSHI);
		String duty = request.getParameter(Constants.REQUEST_PARAMETER_DUTY);
		String team = request.getParameter(Constants.REQUEST_PARAMETER_TEAM);

		Long transferID = null;
		Long problemID = 0l;
		Integer tendencyTypeID = 0;
		Calendar writeDate = null;

		try {
			transferID = new Long(transferIDStr);
		} catch (Exception e) {
		}
		try {
			problemID = new Long(problemIDStr);
		} catch (Exception e) {
		}

		try {
			tendencyTypeID = new Integer(tendencyTypeIDStr);
		} catch (Exception e) {
		}

		try {
			writeDate = Util.convertStrToDate(writeDateStr);
		} catch (Exception e) {
		}

		if (!Util.isNullOrEmpty(problemTitle)) {
			problemTitle = Util.isoToUTF8(problemTitle);
		}

		if (!Util.isNullOrEmpty(problemContent)) {
			problemContent = Util.isoToUTF8(problemContent);
		}

		if (!Util.isNullOrEmpty(zhenggaiCuoshi)) {
			zhenggaiCuoshi = Util.isoToUTF8(zhenggaiCuoshi);
		}
		if (!Util.isNullOrEmpty(reason)) {
			reason = Util.isoToUTF8(reason);
		}

		if (!Util.isNullOrEmpty(loss)) {
			loss = Util.isoToUTF8(loss);
		}
		if (!Util.isNullOrEmpty(duty)) {
			duty = Util.isoToUTF8(duty);
		}
		if (!Util.isNullOrEmpty(team)) {
			team = Util.isoToUTF8(team);
		}

		ProblemDao problemDao = DaoCreator.createProblemDao();
		if (transferID == null) {
			this.createProblemTransfer(request, problemID);
		}
		boolean isSuccess = this.feedbackProblem(request);

		if (isSuccess) {
			User sessionUser = (User) request.getSession().getAttribute(Constants.SESSION_USER);
			isSuccess = problemDao.convertTendency(problemID, tendencyTypeID, writeDate, problemTitle, problemContent, loss, reason,
					zhenggaiCuoshi, duty, team, sessionUser.getId());
		}

		return isSuccess;

	}

	public boolean convertTendencyByCopy(HttpServletRequest request) {
		String problemIDStr = request.getParameter(Constants.REQUEST_PARAMETER_ID);
		String tendencyTypeIDStr = request.getParameter(Constants.REQUEST_PARAMETER_TENDENCY_TYPE_ID);
		String problemTitle = request.getParameter(Constants.REQUEST_PARAMETER_PROBLEM_TITLE);
		String writeDateStr = request.getParameter(Constants.REQUEST_PARAMETER_WRITE_DATE);
		String problemContent = request.getParameter(Constants.REQUEST_PARAMETER_PROBLEM_CONTENT);
		String loss = request.getParameter(Constants.REQUEST_PARAMETER_LOSS);
		String reason = request.getParameter(Constants.REQUEST_PARAMETER_REASON);
		String zhenggaiCuoshi = request.getParameter(Constants.REQUEST_PARAMETER_ZHENGGAI_CUOSHI);
		String duty = request.getParameter(Constants.REQUEST_PARAMETER_DUTY);
		String team = request.getParameter(Constants.REQUEST_PARAMETER_TEAM);

		Long problemID = 0l;
		Integer tendencyTypeID = 0;
		Calendar writeDate = null;

		try {
			problemID = new Long(problemIDStr);
		} catch (Exception e) {
		}

		try {
			tendencyTypeID = new Integer(tendencyTypeIDStr);
		} catch (Exception e) {
		}

		try {
			writeDate = Util.convertStrToDate(writeDateStr);
		} catch (Exception e) {
		}

		if (!Util.isNullOrEmpty(problemTitle)) {
			problemTitle = Util.isoToUTF8(problemTitle);
		}

		if (!Util.isNullOrEmpty(problemContent)) {
			problemContent = Util.isoToUTF8(problemContent);
		}

		if (!Util.isNullOrEmpty(zhenggaiCuoshi)) {
			zhenggaiCuoshi = Util.isoToUTF8(zhenggaiCuoshi);
		}
		if (!Util.isNullOrEmpty(reason)) {
			reason = Util.isoToUTF8(reason);
		}

		if (!Util.isNullOrEmpty(loss)) {
			loss = Util.isoToUTF8(loss);
		}
		if (!Util.isNullOrEmpty(duty)) {
			duty = Util.isoToUTF8(duty);
		}
		if (!Util.isNullOrEmpty(team)) {
			team = Util.isoToUTF8(team);
		}

		ProblemDao problemDao = DaoCreator.createProblemDao();
		Problem problem = problemDao.getProblemByID(problemID);

		problem.setWriteTime(Calendar.getInstance());
		boolean isSuccess = problemDao.addProblem(problem);
		if (!isSuccess) {
			request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_CONVERT_FAIL);
			return false;
		}

		// Change problemID
		problemID = problem.getId();

		isSuccess = this.createProblemTransfer(request, problemID);
		if (!isSuccess) {
			request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_CONVERT_FAIL);
			return false;
		}

		User sessionUser = (User) request.getSession().getAttribute(Constants.SESSION_USER);
		ProblemTransfer transfer = problemDao.getProblemTransfer(sessionUser.getId(), problemID, sessionUser.getId());
		isSuccess = this.feedbackProblem(request, String.valueOf(problemID), String.valueOf(transfer.getId()));
		if (!isSuccess) {
			problemDao.deleteProblemByIDList(new Long[] { problemID });
			// Feedback already set error information.
			return false;
		}

		isSuccess = problemDao.convertTendency(problemID, tendencyTypeID, writeDate, problemTitle, problemContent, loss, reason,
				zhenggaiCuoshi, duty, team, sessionUser.getId());
		if (!isSuccess) {
			request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_CONVERT_FAIL);
			return false;
		}
		return isSuccess;
	}

	public boolean feedbackDefect(HttpServletRequest request) {
		String processMethodStr = request.getParameter(Constants.REQUEST_PARAMETER_PROCESS_METHOD);
		String transferIDStr = request.getParameter(Constants.REQUEST_PARAMETER_TRANSFER_ID);
		String problemIDStr = request.getParameter(Constants.REQUEST_PARAMETER_ID);
		Long transferID = null;
		Long problemID = 0l;
		try {
			transferID = new Long(transferIDStr);
		} catch (Exception e) {
		}
		try {
			problemID = new Long(problemIDStr);
		} catch (Exception e) {
		}
		int processMethod = 0;
		try {
			processMethod = Integer.parseInt(processMethodStr);
		} catch (Exception e) {
		}

		User sessionUser = (User) request.getSession().getAttribute(Constants.SESSION_USER);
		RoleDao roleDao = DaoCreator.createRoleDao();
		ProblemDao problemDao = DaoCreator.createProblemDao();
		Problem problem = problemDao.getProblemByID(problemID);

		if (!roleDao.hasRight(Constants.AUTH_TYPE_DEFECT, sessionUser.getRoleID(), processMethod)) {
			request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_HAS_NOT_RIGHT_TO_PROCESS);
			return false;
		}

		if (!this.canbeProcessed(request, Constants.PROBLEM_TYPE_DEFECT, sessionUser, problem)) {
			return false;
		}

		if (transferID == null) {
			this.createProblemTransfer(request, problemID);
		}

		boolean isSuccess = feedbackProblem(request);
		if (!isSuccess) {
			return false;
		}

		String problemTitle = request.getParameter(Constants.REQUEST_PARAMETER_PROBLEM_TITLE);
		String problemContent = request.getParameter(Constants.REQUEST_PARAMETER_PROBLEM_CONTENT);
		String loss = request.getParameter(Constants.REQUEST_PARAMETER_LOSS);
		String reason = request.getParameter(Constants.REQUEST_PARAMETER_REASON);
		String zhenggaiCuoshi = request.getParameter(Constants.REQUEST_PARAMETER_ZHENGGAI_CUOSHI);
		String duty = request.getParameter(Constants.REQUEST_PARAMETER_DUTY);
		String team = request.getParameter(Constants.REQUEST_PARAMETER_TEAM);

		if (!Util.isNullOrEmpty(problemTitle)) {
			problemTitle = Util.isoToUTF8(problemTitle);
		}

		if (!Util.isNullOrEmpty(problemContent)) {
			problemContent = Util.isoToUTF8(problemContent);
		}

		if (!Util.isNullOrEmpty(zhenggaiCuoshi)) {
			zhenggaiCuoshi = Util.isoToUTF8(zhenggaiCuoshi);
		}
		if (!Util.isNullOrEmpty(reason)) {
			reason = Util.isoToUTF8(reason);
		}

		if (!Util.isNullOrEmpty(loss)) {
			loss = Util.isoToUTF8(loss);
		}
		if (!Util.isNullOrEmpty(duty)) {
			duty = Util.isoToUTF8(duty);
		}
		if (!Util.isNullOrEmpty(team)) {
			team = Util.isoToUTF8(team);
		}

		boolean isSuccess2 = problemDao.updateDefect(problemID, problemTitle, problemContent, loss, reason, zhenggaiCuoshi, duty, team);

		return isSuccess2;
	}

	public boolean feedbackShutdown(HttpServletRequest request) {
		String processMethodStr = request.getParameter(Constants.REQUEST_PARAMETER_PROCESS_METHOD);
		String transferIDStr = request.getParameter(Constants.REQUEST_PARAMETER_TRANSFER_ID);
		String problemIDStr = request.getParameter(Constants.REQUEST_PARAMETER_ID);
		Long transferID = null;
		Long problemID = 0l;
		try {
			transferID = new Long(transferIDStr);
		} catch (Exception e) {
		}
		try {
			problemID = new Long(problemIDStr);
		} catch (Exception e) {
		}
		int processMethod = 0;
		try {
			processMethod = Integer.parseInt(processMethodStr);
		} catch (Exception e) {
		}

		ProblemDao problemDao = DaoCreator.createProblemDao();
		Problem problem = problemDao.getProblemByID(problemID);
		int problemType = problem.getProblemType();
		int authType = 0;
		if (problemType == Constants.PROBLEM_TYPE_NOTPLANED_SHUTDOWN) {
			authType = Constants.AUTH_TYPE_NOTPLANED_SHUTDOWN;
		} else if (problemType == Constants.PROBLEM_TYPE_TEMP_SHUTDOWN) {
			authType = Constants.AUTH_TYPE_TEMP_SHUTDOWN;
		}

		User sessionUser = (User) request.getSession().getAttribute(Constants.SESSION_USER);
		RoleDao roleDao = DaoCreator.createRoleDao();
		if (!roleDao.hasRight(authType, sessionUser.getRoleID(), processMethod)) {
			request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_HAS_NOT_RIGHT_TO_PROCESS);
			return false;
		}

		if (processMethod == Constants.PROCESS_METHOD_CLOSE) {
			boolean canClose = false;
			Role userRole = roleDao.getRoleByUserID(sessionUser.getId());
			if ((userRole.getRoleType() & (Constants.ROLE_TYPE_CHUZHANG | Constants.ROLE_TYPE_FUCHUZHANG)) > 0) {
				if (sessionUser.getDepartment1ID().equals(Constants.DEPARTMENT1_ID_SHENGCHANDIAODUCHU)) {
					canClose = true;
				}
			}

			if (!canClose) {
				request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_IS_NOT_AUTHORIZED_SHUTDOWN_CLOSE);
				return false;
			}
		}

		if (!this.canbeProcessed(request, problemType, sessionUser, problem)) {
			return false;
		}

		if (transferID == null) {
			this.createProblemTransfer(request, problemID);
		}

		boolean isSuccess = feedbackProblem(request);
		if (!isSuccess) {
			return false;
		}

		int[] currentTime = Util.getCurrentDate();
		String problemTitle = request.getParameter(Constants.REQUEST_PARAMETER_PROBLEM_TITLE);
		String problemContent = request.getParameter(Constants.REQUEST_PARAMETER_PROBLEM_CONTENT);
		String loss = request.getParameter(Constants.REQUEST_PARAMETER_LOSS);
		String reason = request.getParameter(Constants.REQUEST_PARAMETER_REASON);
		String zhenggaiCuoshi = request.getParameter(Constants.REQUEST_PARAMETER_ZHENGGAI_CUOSHI);
		String duty = request.getParameter(Constants.REQUEST_PARAMETER_DUTY);
		String team = request.getParameter(Constants.REQUEST_PARAMETER_TEAM);

		Integer startYear = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_YEAR, currentTime[0]);
		Integer startMonth = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_MONTH, currentTime[1]);
		Integer startDay = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_DAY, currentTime[2]);
		Integer startHour = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_HOUR, currentTime[3]);
		Integer startMinute = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_MINUTE, currentTime[4]);

		Integer endYear = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_END_YEAR, currentTime[0]);
		Integer endMonth = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_END_MONTH, currentTime[1]);
		Integer endDay = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_END_DAY, currentTime[2]);
		Integer endHour = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_END_HOUR, currentTime[3]);
		Integer endMinute = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_END_MINUTE, currentTime[4]);

		Calendar periodStart = Util.getCalendar(new int[] { startYear, startMonth, startDay, startHour, startMinute, 0 });
		Calendar periodEnd = Util.getCalendar(new int[] { endYear, endMonth, endDay, endHour, endMinute, 0 });

		if (!Util.isNullOrEmpty(problemTitle)) {
			problemTitle = Util.isoToUTF8(problemTitle);
		}

		if (!Util.isNullOrEmpty(problemContent)) {
			problemContent = Util.isoToUTF8(problemContent);
		}

		if (!Util.isNullOrEmpty(zhenggaiCuoshi)) {
			zhenggaiCuoshi = Util.isoToUTF8(zhenggaiCuoshi);
		}
		if (!Util.isNullOrEmpty(reason)) {
			reason = Util.isoToUTF8(reason);
		}

		if (!Util.isNullOrEmpty(loss)) {
			loss = Util.isoToUTF8(loss);
		}
		if (!Util.isNullOrEmpty(duty)) {
			duty = Util.isoToUTF8(duty);
		}
		if (!Util.isNullOrEmpty(team)) {
			team = Util.isoToUTF8(team);
		}

		boolean isSuccess2 = problemDao.updateShutdown(problemID, problemTitle, problemContent, loss, reason, zhenggaiCuoshi, duty, team,
				periodStart, periodEnd);

		return isSuccess2;
	}

	public boolean feedbackTendency(HttpServletRequest request) {
		String processMethodStr = request.getParameter(Constants.REQUEST_PARAMETER_PROCESS_METHOD);
		String transferIDStr = request.getParameter(Constants.REQUEST_PARAMETER_TRANSFER_ID);
		String problemIDStr = request.getParameter(Constants.REQUEST_PARAMETER_ID);
		Long transferID = null;
		Long problemID = 0l;
		try {
			transferID = new Long(transferIDStr);
		} catch (Exception e) {
		}
		try {
			problemID = new Long(problemIDStr);
		} catch (Exception e) {
		}
		int processMethod = 0;
		try {
			processMethod = Integer.parseInt(processMethodStr);
		} catch (Exception e) {
		}

		User sessionUser = (User) request.getSession().getAttribute(Constants.SESSION_USER);
		RoleDao roleDao = DaoCreator.createRoleDao();
		ProblemDao problemDao = DaoCreator.createProblemDao();
		Problem problem = problemDao.getProblemByID(problemID);

		if (!roleDao.hasRight(Constants.AUTH_TYPE_TENDENCY, sessionUser.getRoleID(), processMethod)) {
			request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_HAS_NOT_RIGHT_TO_PROCESS);
			return false;
		}

		if (!this.canbeProcessed(request, Constants.PROBLEM_TYPE_TENDENCY, sessionUser, problem)) {
			return false;
		}

		if (transferID == null) {
			this.createProblemTransfer(request, problemID);
		}

		boolean isSuccess = feedbackProblem(request);
		if (!isSuccess) {
			return false;
		}
		String problemTitle = request.getParameter(Constants.REQUEST_PARAMETER_PROBLEM_TITLE);
		String problemContent = request.getParameter(Constants.REQUEST_PARAMETER_PROBLEM_CONTENT);
		String loss = request.getParameter(Constants.REQUEST_PARAMETER_LOSS);
		String reason = request.getParameter(Constants.REQUEST_PARAMETER_REASON);
		String zhenggaiCuoshi = request.getParameter(Constants.REQUEST_PARAMETER_ZHENGGAI_CUOSHI);
		String duty = request.getParameter(Constants.REQUEST_PARAMETER_DUTY);
		String team = request.getParameter(Constants.REQUEST_PARAMETER_TEAM);

		if (!Util.isNullOrEmpty(problemTitle)) {
			problemTitle = Util.isoToUTF8(problemTitle);
		}

		if (!Util.isNullOrEmpty(problemContent)) {
			problemContent = Util.isoToUTF8(problemContent);
		}

		if (!Util.isNullOrEmpty(zhenggaiCuoshi)) {
			zhenggaiCuoshi = Util.isoToUTF8(zhenggaiCuoshi);
		}
		if (!Util.isNullOrEmpty(reason)) {
			reason = Util.isoToUTF8(reason);
		}

		if (!Util.isNullOrEmpty(loss)) {
			loss = Util.isoToUTF8(loss);
		}
		if (!Util.isNullOrEmpty(duty)) {
			duty = Util.isoToUTF8(duty);
		}
		if (!Util.isNullOrEmpty(team)) {
			team = Util.isoToUTF8(team);
		}

		boolean isSuccess2 = problemDao.updateTendency(problemID, problemTitle, problemContent, loss, reason, zhenggaiCuoshi, duty, team);

		return isSuccess2;
	}

	protected boolean canbeProcessed(HttpServletRequest request, int problemType, User user, Problem problem) {
		Long depart1ID = user.getDepartment1ID();
		DepartmentDao departmentDao = DaoCreator.createDepartmentDao();

		Department1 depart1 = departmentDao.getDepartment1ByID(depart1ID);

		if (problem.getProcessStatus() == Constants.PROBLEM_STATUS_OTHER_DEPART_HELP) {
			return true;
		} else {
			if (depart1.getDepartmentType() == Constants.DEPARTMENT_TYPE_SHIYEBU && problem.isProcessingByChushi()) {
				request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_IS_PROCESSING_BY_CHUSHI);
				return false;
			}
		}

		return true;
	}

	public boolean writeAccidentRegisteform(HttpServletRequest request) {
		int[] currentTime = Util.getCurrentDate();
		String accidentTypeIDStr = request.getParameter(Constants.REQUEST_PARAMETER_ACCIDENT_TYPE_ID);
		String accidentName = request.getParameter(Constants.REQUEST_PARAMETER_ACCIDENT_NAME);
		String casualty = request.getParameter(Constants.REQUEST_PARAMETER_CASUALTY);
		String loss = request.getParameter(Constants.REQUEST_PARAMETER_LOSS);
		String overview = request.getParameter(Constants.REQUEST_PARAMETER_OVERVIEW);
		String handle = request.getParameter(Constants.REQUEST_PARAMETER_HANDLE);

		Integer accidentTypeID = null;
		Integer startYear = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_YEAR, currentTime[0]);
		Integer startMonth = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_MONTH, currentTime[1]);
		Integer startDay = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_DAY, currentTime[2]);
		Integer startHour = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_HOUR, currentTime[3]);
		Integer startMinute = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_MINUTE, currentTime[4]);

		try {
			accidentTypeID = Integer.parseInt(accidentTypeIDStr);
		} catch (Exception e) {
		}

		if (!Util.isNullOrEmpty(accidentName)) {
			accidentName = Util.isoToUTF8(accidentName);
		}
		if (!Util.isNullOrEmpty(casualty)) {
			casualty = Util.isoToUTF8(casualty);
		}
		if (!Util.isNullOrEmpty(loss)) {
			loss = Util.isoToUTF8(loss);
		}
		if (!Util.isNullOrEmpty(overview)) {
			overview = Util.isoToUTF8(overview);
		}
		if (!Util.isNullOrEmpty(handle)) {
			handle = Util.isoToUTF8(handle);
		}

		ProblemDao problemDao = DaoCreator.createProblemDao();
		AccidentDao accidentDao = DaoCreator.createAccidentDao();

		boolean isSuccess = this.writeProblem(request);
		Problem newProblem = (Problem) request.getAttribute(Constants.REQUEST_ATTRIBUTE_PROBLEM);
		if (!isSuccess && newProblem != null) {
			problemDao.deleteProblemByIDList(new Long[] { newProblem.getId() });
			return false;
		}

		problemDao.updateProblem(newProblem.getId(), Constants.PROBLEM_TYPE_ACCIDENT_REGISTERFORM, newProblem.getProblemTitle(),
				newProblem.getProblemContent(), newProblem.getProblemZhenggai(), newProblem.getGrade(), null, null, null, null, null,
				newProblem.getProcessStatus());

		Calendar accidentTime = Util.getCalendar(new int[] { startYear, startMonth, startDay, startHour, startMinute, 0 });
		User sessionUser = (User) request.getSession().getAttribute(Constants.SESSION_USER);
		Long problemID = newProblem.getId();

		// transfer
		isSuccess = this.createProblemTransfer(request, problemID);
		if (!isSuccess) {
			problemDao.deleteProblemByIDList(new Long[] { problemID });
			return false;
		}

		int accidentStatus = Constants.ACCIDENT_STATUS_UPDATE;
		if (newProblem.getProcessStatus() >= Constants.PROBLEM_STATUS_CLOSE) {
			accidentStatus = Constants.ACCIDENT_STATUS_COMPLETE;

			ProblemTransfer latestTransfer = getLatestTransfer(problemID);
			problemDao.processProblem("", latestTransfer.getId(), problemID, sessionUser.getId(), Constants.PROBLEM_STATUS_CLOSE,
					Constants.PROCESS_METHOD_CLOSE, null, newProblem.getEscalateDepart1ID(), newProblem.getGrade(),
					newProblem.isProcessingByChushi());
		}

		isSuccess = accidentDao.addAccidentRegisterform(newProblem.getId(), accidentTypeID, accidentTime, accidentStatus, accidentName,
				overview, casualty, loss, handle, Calendar.getInstance(), sessionUser.getId());
		if (!isSuccess) {
			problemDao.deleteProblemByIDList(new Long[] { newProblem.getId() });
			request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_ACCIDENT_REGISTERFORM_FAIL);
			return false;
		}
		return true;
	}

	public boolean writeAccidentInfosheet(HttpServletRequest request) {
		int[] currentTime = Util.getCurrentDate();

		String accidentName = request.getParameter(Constants.REQUEST_PARAMETER_ACCIDENT_NAME);
		String casualty = request.getParameter(Constants.REQUEST_PARAMETER_CASUALTY);
		String loss = request.getParameter(Constants.REQUEST_PARAMETER_LOSS);
		String overview = request.getParameter(Constants.REQUEST_PARAMETER_OVERVIEW);
		String handle = request.getParameter(Constants.REQUEST_PARAMETER_HANDLE);
		String reason = request.getParameter(Constants.REQUEST_PARAMETER_REASON);
		String moral = request.getParameter(Constants.REQUEST_PARAMETER_MORAL);

		Integer seriousInjuryCount = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_SERIOUS_INJURY_COUNT, (Integer) null);
		Integer deathCount = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_SERIOUS_INJURY_COUNT, (Integer) null);

		Integer accidentTypeID = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_ACCIDENT_TYPE_ID, (Integer) null);
		Integer startYear = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_YEAR, currentTime[0]);
		Integer startMonth = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_MONTH, currentTime[1]);
		Integer startDay = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_DAY, currentTime[2]);
		Integer startHour = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_HOUR, currentTime[3]);
		Integer startMinute = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_MINUTE, currentTime[4]);

		Long facadeID = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_FACADE_ID, (Long) null);

		if (!Util.isNullOrEmpty(accidentName)) {
			accidentName = Util.isoToUTF8(accidentName);
		}
		if (!Util.isNullOrEmpty(casualty)) {
			casualty = Util.isoToUTF8(casualty);
		}
		if (!Util.isNullOrEmpty(loss)) {
			loss = Util.isoToUTF8(loss);
		}
		if (!Util.isNullOrEmpty(overview)) {
			overview = Util.isoToUTF8(overview);
		}
		if (!Util.isNullOrEmpty(handle)) {
			handle = Util.isoToUTF8(handle);
		}
		if (!Util.isNullOrEmpty(reason)) {
			reason = Util.isoToUTF8(reason);
		}
		if (!Util.isNullOrEmpty(moral)) {
			moral = Util.isoToUTF8(moral);
		}
		Calendar accidentTime = Util.getCalendar(new int[] { startYear, startMonth, startDay, startHour, startMinute, 0 });

		List<AccidentCasualty> accidentCasualtyList = (List<AccidentCasualty>) request.getSession().getAttribute(
				Constants.SESSION_ACCIDENT_CASUALTY);

		ProblemDao problemDao = DaoCreator.createProblemDao();
		AccidentDao accidentDao = DaoCreator.createAccidentDao();

		boolean isSuccess = this.writeProblem(request);
		Problem newProblem = (Problem) request.getAttribute(Constants.REQUEST_ATTRIBUTE_PROBLEM);
		if (!isSuccess && newProblem != null) {
			problemDao.deleteProblemByIDList(new Long[] { newProblem.getId() });
			return false;
		}

		problemDao.updateProblem(newProblem.getId(), Constants.PROBLEM_TYPE_ACCIDENT_INFOSHEET, newProblem.getProblemTitle(),
				newProblem.getProblemContent(), newProblem.getProblemZhenggai(), newProblem.getGrade(), null, null, null, null, null,
				newProblem.getProcessStatus());

		User sessionUser = (User) request.getSession().getAttribute(Constants.SESSION_USER);
		Long problemID = newProblem.getId();

		// transfer
		this.createProblemTransfer(request, problemID);
		ProblemTransfer transfer = problemDao.getProblemTransfer(sessionUser.getId(), problemID, sessionUser.getId());
		isSuccess = this.feedbackProblem(request, String.valueOf(problemID), String.valueOf(transfer.getId()));
		if (!isSuccess) {
			problemDao.deleteProblemByIDList(new Long[] { problemID });
			return false;
		}

		// Add accident infosheet
		isSuccess = accidentDao.addAccidentInfosheet(problemID, accidentTypeID, accidentTime, Constants.ACCIDENT_STATUS_UPDATE,
				accidentName, overview, casualty, loss, reason, moral, seriousInjuryCount, deathCount, handle, Calendar.getInstance(),
				sessionUser.getId(), facadeID);
		if (!isSuccess) {
			problemDao.deleteProblemByIDList(new Long[] { newProblem.getId() });
			request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_ACCIDENT_REGISTERFORM_FAIL);
			return false;
		}

		// add accident quickreport
		isSuccess = accidentDao.addAccidentQuickreport(problemID, accidentTypeID, accidentTime, Constants.ACCIDENT_STATUS_UPDATE, overview,
				casualty, loss, reason, moral, seriousInjuryCount, deathCount, handle, Calendar.getInstance(), sessionUser.getId(),
				accidentName, facadeID);
		if (!isSuccess) {
			problemDao.deleteProblemByIDList(new Long[] { newProblem.getId() });
			request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_ACCIDENT_REGISTERFORM_FAIL);
			return false;
		}

		// add accident casualty
		if (accidentCasualtyList != null && accidentCasualtyList.size() > 0) {
			isSuccess = accidentDao.addAccidentCasualty(problemID, accidentCasualtyList);
		}

		if (!isSuccess) {
			problemDao.deleteProblemByIDList(new Long[] { newProblem.getId() });
			request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_ACCIDENT_REGISTERFORM_FAIL);
		}

		return isSuccess;
	}

	public boolean writeAccidentReport(HttpServletRequest request) {
		int[] currentTime = Util.getCurrentDate();

		String accidentName = request.getParameter(Constants.REQUEST_PARAMETER_ACCIDENT_NAME);
		String casualty = request.getParameter(Constants.REQUEST_PARAMETER_CASUALTY);
		String loss = request.getParameter(Constants.REQUEST_PARAMETER_LOSS);
		String overview = request.getParameter(Constants.REQUEST_PARAMETER_OVERVIEW);
		String reason = request.getParameter(Constants.REQUEST_PARAMETER_REASON);
		String moral = request.getParameter(Constants.REQUEST_PARAMETER_MORAL);
		String duty = request.getParameter(Constants.REQUEST_PARAMETER_DUTY);
		String team = request.getParameter(Constants.REQUEST_PARAMETER_TEAM);
		String introspection = request.getParameter(Constants.REQUEST_PARAMETER_INTROSPECTON);
		String reviewDetail = request.getParameter(Constants.REQUEST_PARAMETER_REVIEW_DETAIL);
		String reviewTeam = request.getParameter(Constants.REQUEST_PARAMETER_REVIEW_TEAM);
		String reviewTimeStr = request.getParameter(Constants.REQUEST_PARAMETER_REVIEW_TIME);

		Integer accidentTypeID = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_ACCIDENT_TYPE_ID, (Integer) null);
		Integer startYear = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_YEAR, currentTime[0]);
		Integer startMonth = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_MONTH, currentTime[1]);
		Integer startDay = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_DAY, currentTime[2]);
		Integer startHour = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_HOUR, currentTime[3]);
		Integer startMinute = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_MINUTE, currentTime[4]);

		Long facadeID = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_FACADE_ID, (Long) null);

		if (!Util.isNullOrEmpty(accidentName)) {
			accidentName = Util.isoToUTF8(accidentName);
		}
		if (!Util.isNullOrEmpty(casualty)) {
			casualty = Util.isoToUTF8(casualty);
		}
		if (!Util.isNullOrEmpty(loss)) {
			loss = Util.isoToUTF8(loss);
		}
		if (!Util.isNullOrEmpty(overview)) {
			overview = Util.isoToUTF8(overview);
		}
		if (!Util.isNullOrEmpty(reason)) {
			reason = Util.isoToUTF8(reason);
		}
		if (!Util.isNullOrEmpty(moral)) {
			moral = Util.isoToUTF8(moral);
		}
		if (!Util.isNullOrEmpty(duty)) {
			duty = Util.isoToUTF8(duty);
		}
		if (!Util.isNullOrEmpty(team)) {
			team = Util.isoToUTF8(team);
		}
		if (!Util.isNullOrEmpty(introspection)) {
			introspection = Util.isoToUTF8(introspection);
		}
		if (!Util.isNullOrEmpty(reviewDetail)) {
			reviewDetail = Util.isoToUTF8(reviewDetail);
		}
		if (!Util.isNullOrEmpty(reviewTeam)) {
			reviewTeam = Util.isoToUTF8(reviewTeam);
		}

		Calendar accidentTime = Util.getCalendar(new int[] { startYear, startMonth, startDay, startHour, startMinute, 0 });
		Calendar reviewTime = null;
		try {
			reviewTime = Util.convertStrToDate(reviewTimeStr);
		} catch (Exception e) {
		}

		ProblemDao problemDao = DaoCreator.createProblemDao();
		AccidentDao accidentDao = DaoCreator.createAccidentDao();

		boolean isSuccess = this.writeProblem(request);
		Problem newProblem = (Problem) request.getAttribute(Constants.REQUEST_ATTRIBUTE_PROBLEM);
		if (!isSuccess && newProblem != null) {
			problemDao.deleteProblemByIDList(new Long[] { newProblem.getId() });
			return false;
		}

		problemDao.updateProblem(newProblem.getId(), Constants.PROBLEM_TYPE_ACCIDENT_REPORT, newProblem.getProblemTitle(),
				newProblem.getProblemContent(), newProblem.getProblemZhenggai(), newProblem.getGrade(), null, null, null, null, null,
				newProblem.getProcessStatus());

		User sessionUser = (User) request.getSession().getAttribute(Constants.SESSION_USER);
		Long problemID = newProblem.getId();

		// transfer
		this.createProblemTransfer(request, problemID);
		ProblemTransfer transfer = problemDao.getProblemTransfer(sessionUser.getId(), problemID, sessionUser.getId());
		isSuccess = this.feedbackProblem(request, String.valueOf(problemID), String.valueOf(transfer.getId()));
		if (!isSuccess) {
			problemDao.deleteProblemByIDList(new Long[] { problemID });
			return false;
		}

		// add report
		isSuccess = accidentDao.addAccidentReport(problemID, accidentTypeID, accidentTime, Constants.ACCIDENT_STATUS_UPDATE, overview,
				casualty, loss, reason, moral, Calendar.getInstance(), sessionUser.getId(), duty, team, introspection, reviewDetail,
				reviewTeam, reviewTime, accidentName, facadeID);
		if (!isSuccess) {
			problemDao.deleteProblemByIDList(new Long[] { newProblem.getId() });
			request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_ACCIDENT_REGISTERFORM_FAIL);
			return false;
		}

		// add checkform1
		isSuccess = accidentDao.addAccidentCheckform(1, problemID, accidentTypeID, accidentTime, Constants.ACCIDENT_STATUS_UPDATE,
				overview, casualty, loss, reason, moral, Calendar.getInstance(), sessionUser.getId(), duty, team, introspection,
				reviewDetail, reviewTeam, reviewTime, accidentName, facadeID);

		if (!isSuccess) {
			problemDao.deleteProblemByIDList(new Long[] { newProblem.getId() });
			request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_ACCIDENT_REGISTERFORM_FAIL);
		}

		return isSuccess;
	}

	public boolean writeAccidentCheckform2(HttpServletRequest request) {
		int[] currentTime = Util.getCurrentDate();

		String accidentName = request.getParameter(Constants.REQUEST_PARAMETER_ACCIDENT_NAME);
		String casualty = request.getParameter(Constants.REQUEST_PARAMETER_CASUALTY);
		String loss = request.getParameter(Constants.REQUEST_PARAMETER_LOSS);
		String overview = null;
		String reason = request.getParameter(Constants.REQUEST_PARAMETER_REASON);
		String moral = request.getParameter(Constants.REQUEST_PARAMETER_MORAL);
		String duty = request.getParameter(Constants.REQUEST_PARAMETER_DUTY);
		String team = null;
		String introspection = request.getParameter(Constants.REQUEST_PARAMETER_INTROSPECTON);
		String reviewDetail = request.getParameter(Constants.REQUEST_PARAMETER_REVIEW_DETAIL);
		String reviewTeam = request.getParameter(Constants.REQUEST_PARAMETER_REVIEW_TEAM);
		String reviewTimeStr = request.getParameter(Constants.REQUEST_PARAMETER_REVIEW_TIME);

		Integer accidentTypeID = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_ACCIDENT_TYPE_ID, (Integer) null);
		Integer startYear = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_YEAR, currentTime[0]);
		Integer startMonth = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_MONTH, currentTime[1]);
		Integer startDay = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_DAY, currentTime[2]);
		Integer startHour = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_HOUR, currentTime[3]);
		Integer startMinute = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_MINUTE, currentTime[4]);

		Long facadeID = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_FACADE_ID, (Long) null);

		if (!Util.isNullOrEmpty(accidentName)) {
			accidentName = Util.isoToUTF8(accidentName);
		}
		if (!Util.isNullOrEmpty(casualty)) {
			casualty = Util.isoToUTF8(casualty);
		}
		if (!Util.isNullOrEmpty(loss)) {
			loss = Util.isoToUTF8(loss);
		}
		if (!Util.isNullOrEmpty(reason)) {
			reason = Util.isoToUTF8(reason);
		}
		if (!Util.isNullOrEmpty(moral)) {
			moral = Util.isoToUTF8(moral);
		}
		if (!Util.isNullOrEmpty(duty)) {
			duty = Util.isoToUTF8(duty);
		}
		if (!Util.isNullOrEmpty(introspection)) {
			introspection = Util.isoToUTF8(introspection);
		}
		if (!Util.isNullOrEmpty(reviewDetail)) {
			reviewDetail = Util.isoToUTF8(reviewDetail);
		}
		if (!Util.isNullOrEmpty(reviewTeam)) {
			reviewTeam = Util.isoToUTF8(reviewTeam);
		}

		Calendar accidentTime = Util.getCalendar(new int[] { startYear, startMonth, startDay, startHour, startMinute, 0 });
		Calendar reviewTime = null;
		try {
			reviewTime = Util.convertStrToDate(reviewTimeStr);
		} catch (Exception e) {
		}

		ProblemDao problemDao = DaoCreator.createProblemDao();
		AccidentDao accidentDao = DaoCreator.createAccidentDao();

		boolean isSuccess = this.writeProblem(request);
		Problem newProblem = (Problem) request.getAttribute(Constants.REQUEST_ATTRIBUTE_PROBLEM);
		if (!isSuccess && newProblem != null) {
			problemDao.deleteProblemByIDList(new Long[] { newProblem.getId() });
			return false;
		}

		problemDao.updateProblem(newProblem.getId(), Constants.PROBLEM_TYPE_ACCIDENT_CHECKFORM2, newProblem.getProblemTitle(),
				newProblem.getProblemContent(), newProblem.getProblemZhenggai(), newProblem.getGrade(), null, null, null, null, null,
				newProblem.getProcessStatus());

		User sessionUser = (User) request.getSession().getAttribute(Constants.SESSION_USER);
		Long problemID = newProblem.getId();

		// transfer
		this.createProblemTransfer(request, problemID);
		ProblemTransfer transfer = problemDao.getProblemTransfer(sessionUser.getId(), problemID, sessionUser.getId());
		isSuccess = this.feedbackProblem(request, String.valueOf(problemID), String.valueOf(transfer.getId()));
		if (!isSuccess) {
			problemDao.deleteProblemByIDList(new Long[] { problemID });
			return false;
		}

		isSuccess = accidentDao.addAccidentCheckform(2, problemID, accidentTypeID, accidentTime, Constants.ACCIDENT_STATUS_UPDATE,
				overview, casualty, loss, reason, moral, Calendar.getInstance(), sessionUser.getId(), duty, team, introspection,
				reviewDetail, reviewTeam, reviewTime, accidentName, facadeID);
		if (!isSuccess) {
			problemDao.deleteProblemByIDList(new Long[] { newProblem.getId() });
			request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_ACCIDENT_REGISTERFORM_FAIL);
			return false;
		}

		return isSuccess;
	}

	public boolean writeAccidentCheckform3(HttpServletRequest request) {
		int[] currentTime = Util.getCurrentDate();

		String accidentName = request.getParameter(Constants.REQUEST_PARAMETER_ACCIDENT_NAME);
		String casualty = request.getParameter(Constants.REQUEST_PARAMETER_CASUALTY);
		String loss = request.getParameter(Constants.REQUEST_PARAMETER_LOSS);
		String overview = null;
		String reason = request.getParameter(Constants.REQUEST_PARAMETER_REASON);
		String moral = request.getParameter(Constants.REQUEST_PARAMETER_MORAL);
		String duty = request.getParameter(Constants.REQUEST_PARAMETER_DUTY);
		String team = null;
		String introspection = request.getParameter(Constants.REQUEST_PARAMETER_INTROSPECTON);
		String reviewDetail = request.getParameter(Constants.REQUEST_PARAMETER_REVIEW_DETAIL);
		String reviewTeam = request.getParameter(Constants.REQUEST_PARAMETER_REVIEW_TEAM);
		String reviewTimeStr = request.getParameter(Constants.REQUEST_PARAMETER_REVIEW_TIME);

		Integer accidentTypeID = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_ACCIDENT_TYPE_ID, (Integer) null);
		Integer startYear = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_YEAR, currentTime[0]);
		Integer startMonth = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_MONTH, currentTime[1]);
		Integer startDay = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_DAY, currentTime[2]);
		Integer startHour = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_HOUR, currentTime[3]);
		Integer startMinute = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_MINUTE, currentTime[4]);

		Long facadeID = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_FACADE_ID, (Long) null);

		if (!Util.isNullOrEmpty(accidentName)) {
			accidentName = Util.isoToUTF8(accidentName);
		}
		if (!Util.isNullOrEmpty(casualty)) {
			casualty = Util.isoToUTF8(casualty);
		}
		if (!Util.isNullOrEmpty(loss)) {
			loss = Util.isoToUTF8(loss);
		}
		if (!Util.isNullOrEmpty(reason)) {
			reason = Util.isoToUTF8(reason);
		}
		if (!Util.isNullOrEmpty(moral)) {
			moral = Util.isoToUTF8(moral);
		}
		if (!Util.isNullOrEmpty(duty)) {
			duty = Util.isoToUTF8(duty);
		}
		if (!Util.isNullOrEmpty(introspection)) {
			introspection = Util.isoToUTF8(introspection);
		}
		if (!Util.isNullOrEmpty(reviewDetail)) {
			reviewDetail = Util.isoToUTF8(reviewDetail);
		}
		if (!Util.isNullOrEmpty(reviewTeam)) {
			reviewTeam = Util.isoToUTF8(reviewTeam);
		}

		Calendar accidentTime = Util.getCalendar(new int[] { startYear, startMonth, startDay, startHour, startMinute, 0 });
		Calendar reviewTime = null;
		try {
			reviewTime = Util.convertStrToDate(reviewTimeStr);
		} catch (Exception e) {
		}

		ProblemDao problemDao = DaoCreator.createProblemDao();
		AccidentDao accidentDao = DaoCreator.createAccidentDao();

		boolean isSuccess = this.writeProblem(request);
		Problem newProblem = (Problem) request.getAttribute(Constants.REQUEST_ATTRIBUTE_PROBLEM);
		if (!isSuccess && newProblem != null) {
			problemDao.deleteProblemByIDList(new Long[] { newProblem.getId() });
			return false;
		}

		problemDao.updateProblem(newProblem.getId(), Constants.PROBLEM_TYPE_ACCIDENT_CHECKFORM3, newProblem.getProblemTitle(),
				newProblem.getProblemContent(), newProblem.getProblemZhenggai(), newProblem.getGrade(), null, null, null, null, null,
				newProblem.getProcessStatus());

		User sessionUser = (User) request.getSession().getAttribute(Constants.SESSION_USER);
		Long problemID = newProblem.getId();

		// transfer
		this.createProblemTransfer(request, problemID);
		ProblemTransfer transfer = problemDao.getProblemTransfer(sessionUser.getId(), problemID, sessionUser.getId());
		isSuccess = this.feedbackProblem(request, String.valueOf(problemID), String.valueOf(transfer.getId()));
		if (!isSuccess) {
			problemDao.deleteProblemByIDList(new Long[] { problemID });
			return false;
		}

		isSuccess = accidentDao.addAccidentCheckform(3, problemID, accidentTypeID, accidentTime, Constants.ACCIDENT_STATUS_UPDATE,
				overview, casualty, loss, reason, moral, Calendar.getInstance(), sessionUser.getId(), duty, team, introspection,
				reviewDetail, reviewTeam, reviewTime, accidentName, facadeID);
		if (!isSuccess) {
			problemDao.deleteProblemByIDList(new Long[] { newProblem.getId() });
			request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_ACCIDENT_REGISTERFORM_FAIL);
			return false;
		}

		return isSuccess;
	}

	public boolean feedbackAccidentRegisterform(HttpServletRequest request) {
		Long transferID = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_TRANSFER_ID, (Long) null);
		Long problemID = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_ID, (Long) null);
		int processMethod = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_PROCESS_METHOD, 0);

		User sessionUser = (User) request.getSession().getAttribute(Constants.SESSION_USER);
		RoleDao roleDao = DaoCreator.createRoleDao();
		ProblemDao problemDao = DaoCreator.createProblemDao();
		AccidentDao accidentDao = DaoCreator.createAccidentDao();
		Problem problem = problemDao.getProblemByID(problemID);

		if (!roleDao.hasRight(Constants.AUTH_TYPE_ACCIDENT_REGISTER, sessionUser.getRoleID(), processMethod)) {
			request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_HAS_NOT_RIGHT_TO_PROCESS);
			return false;
		}

		if (!this.canbeProcessed(request, Constants.PROBLEM_TYPE_ACCIDENT_REGISTERFORM, sessionUser, problem)) {
			return false;
		}

		if (transferID == null) {
			this.createProblemTransfer(request, problemID);
		}

		boolean isSuccess = feedbackProblem(request);

		if (!isSuccess) {
			return false;
		}
		int[] currentTime = Util.getCurrentDate();
		String accidentTypeIDStr = request.getParameter(Constants.REQUEST_PARAMETER_ACCIDENT_TYPE_ID);
		String accidentName = request.getParameter(Constants.REQUEST_PARAMETER_ACCIDENT_NAME);
		String casualty = request.getParameter(Constants.REQUEST_PARAMETER_CASUALTY);
		String loss = request.getParameter(Constants.REQUEST_PARAMETER_LOSS);
		String overview = request.getParameter(Constants.REQUEST_PARAMETER_OVERVIEW);
		String handle = request.getParameter(Constants.REQUEST_PARAMETER_HANDLE);

		Integer accidentTypeID = null;
		Integer startYear = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_YEAR, currentTime[0]);
		Integer startMonth = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_MONTH, currentTime[1]);
		Integer startDay = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_DAY, currentTime[2]);
		Integer startHour = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_HOUR, currentTime[3]);
		Integer startMinute = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_MINUTE, currentTime[4]);

		try {
			accidentTypeID = Integer.parseInt(accidentTypeIDStr);
		} catch (Exception e) {
		}

		if (!Util.isNullOrEmpty(accidentName)) {
			accidentName = Util.isoToUTF8(accidentName);
		}
		if (!Util.isNullOrEmpty(casualty)) {
			casualty = Util.isoToUTF8(casualty);
		}
		if (!Util.isNullOrEmpty(loss)) {
			loss = Util.isoToUTF8(loss);
		}
		if (!Util.isNullOrEmpty(overview)) {
			overview = Util.isoToUTF8(overview);
		}
		if (!Util.isNullOrEmpty(handle)) {
			handle = Util.isoToUTF8(handle);
		}
		Calendar accidentTime = Util.getCalendar(new int[] { startYear, startMonth, startDay, startHour, startMinute, 0 });

		int accidentStatus = 0;
		if (processMethod == Constants.PROCESS_METHOD_CLOSE || processMethod == Constants.PROCESS_METHOD_PROVE) {
			accidentStatus = Constants.ACCIDENT_STATUS_COMPLETE;
		} else {
			accidentStatus = Constants.ACCIDENT_STATUS_UPDATE;
		}

		problemDao.updateProblem(problemID, Constants.COLUMN_NAME_PROBLEM_TITLE, accidentName);

		boolean isSuccess2 = accidentDao.updateAccidentRegisterform(problemID, accidentTypeID, accidentTime, accidentStatus, accidentName,
				overview, casualty, loss, handle);

		return isSuccess2;
	}

	public boolean feedbackAccidentInfosheet(HttpServletRequest request) {
		Long transferID = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_TRANSFER_ID, (Long) null);
		Long problemID = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_ID, (Long) null);
		int processMethod = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_PROCESS_METHOD, 0);

		User sessionUser = (User) request.getSession().getAttribute(Constants.SESSION_USER);
		RoleDao roleDao = DaoCreator.createRoleDao();
		ProblemDao problemDao = DaoCreator.createProblemDao();
		AccidentDao accidentDao = DaoCreator.createAccidentDao();
		Problem problem = problemDao.getProblemByID(problemID);
		Role role = roleDao.getRoleByUserID(sessionUser.getId());

		if (!roleDao.hasRight(Constants.AUTH_TYPE_ACCIDENT_FEEDBACK, sessionUser.getRoleID(), processMethod)) {
			request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_HAS_NOT_RIGHT_TO_PROCESS);
			return false;
		}

		if (!this.canbeProcessed(request, Constants.PROBLEM_TYPE_ACCIDENT_REGISTERFORM, sessionUser, problem)) {
			return false;
		}

		if (transferID == null) {
			this.createProblemTransfer(request, problemID);
		}

		boolean isSuccess = feedbackProblem(request);

		if (!isSuccess) {
			return false;
		}

		int[] currentTime = Util.getCurrentDate();

		String accidentName = request.getParameter(Constants.REQUEST_PARAMETER_ACCIDENT_NAME);
		String casualty = request.getParameter(Constants.REQUEST_PARAMETER_CASUALTY);
		String loss = request.getParameter(Constants.REQUEST_PARAMETER_LOSS);
		String overview = request.getParameter(Constants.REQUEST_PARAMETER_OVERVIEW);
		String handle = request.getParameter(Constants.REQUEST_PARAMETER_HANDLE);
		String reason = request.getParameter(Constants.REQUEST_PARAMETER_REASON);
		String moral = request.getParameter(Constants.REQUEST_PARAMETER_MORAL);
		String sendbackMsg = request.getParameter(Constants.REQUEST_PARAMETER_SENDBACK_MSG);

		Integer seriousInjuryCount = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_SERIOUS_INJURY_COUNT, (Integer) null);
		Integer deathCount = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_SERIOUS_INJURY_COUNT, (Integer) null);

		Integer accidentTypeID = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_ACCIDENT_TYPE_ID, (Integer) null);
		Integer startYear = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_YEAR, currentTime[0]);
		Integer startMonth = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_MONTH, currentTime[1]);
		Integer startDay = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_DAY, currentTime[2]);
		Integer startHour = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_HOUR, currentTime[3]);
		Integer startMinute = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_MINUTE, currentTime[4]);

		if (!Util.isNullOrEmpty(accidentName)) {
			accidentName = Util.isoToUTF8(accidentName);
		}
		if (!Util.isNullOrEmpty(casualty)) {
			casualty = Util.isoToUTF8(casualty);
		}
		if (!Util.isNullOrEmpty(loss)) {
			loss = Util.isoToUTF8(loss);
		}
		if (!Util.isNullOrEmpty(overview)) {
			overview = Util.isoToUTF8(overview);
		}
		if (!Util.isNullOrEmpty(handle)) {
			handle = Util.isoToUTF8(handle);
		}
		if (!Util.isNullOrEmpty(reason)) {
			reason = Util.isoToUTF8(reason);
		}
		if (!Util.isNullOrEmpty(moral)) {
			moral = Util.isoToUTF8(moral);
		}
		if (!Util.isNullOrEmpty(sendbackMsg)) {
			sendbackMsg = Util.isoToUTF8(sendbackMsg);
		}

		Calendar accidentTime = Util.getCalendar(new int[] { startYear, startMonth, startDay, startHour, startMinute, 0 });

		List<AccidentCasualty> accidentCasualtyList = (List<AccidentCasualty>) request.getSession().getAttribute(
				Constants.SESSION_ACCIDENT_CASUALTY);

		int accidentStatus = 0;
		if (processMethod == Constants.PROCESS_METHOD_CLOSE || processMethod == Constants.PROCESS_METHOD_PROVE) {
			accidentStatus = Constants.ACCIDENT_STATUS_COMPLETE;
		} else {
			accidentStatus = Constants.ACCIDENT_STATUS_UPDATE;
		}

		if (processMethod == Constants.PROCESS_METHOD_CLOSE || processMethod == Constants.PROCESS_METHOD_PROVE) {
			sendbackMsg = null;
		} else if (processMethod == Constants.PROCESS_METHOD_ESCALATE && problem.getEscalateDepart1ID() == null
				&& role.getRoleType() == Constants.ROLE_TYPE_BUZHANG) {
			sendbackMsg = null;
		} else if (processMethod != Constants.PROCESS_METHOD_SENDBACK) {
			sendbackMsg = accidentDao.getInfosheetByID(problemID).getSendbackMsg();
		}

		problemDao.updateProblem(problemID, Constants.COLUMN_NAME_PROBLEM_TITLE, accidentName);
		isSuccess = accidentDao.updateAccidentInfosheet(problemID, accidentTypeID, accidentTime, accidentStatus, accidentName, overview,
				casualty, loss, reason, moral, seriousInjuryCount, deathCount, handle, sendbackMsg);
		isSuccess = accidentDao.updateAccidentQuickreport(problemID, accidentTypeID, accidentTime, accidentStatus, overview, casualty,
				loss, reason, moral, seriousInjuryCount, deathCount, handle, accidentName, sendbackMsg);

		if (!isSuccess) {
			request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_ACCIDENT_UPDATE_FAIL);
			return false;
		}

		isSuccess = accidentDao.deleteAccidentCasualtyByProblemID(new Long[] { problemID });
		if (accidentCasualtyList != null && accidentCasualtyList.size() > 0) {
			isSuccess = accidentDao.addAccidentCasualty(problemID, accidentCasualtyList);
		}

		return isSuccess;
	}

	public boolean feedbackAccidentReport(HttpServletRequest request) {
		Long transferID = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_TRANSFER_ID, (Long) null);
		Long problemID = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_ID, (Long) null);
		int processMethod = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_PROCESS_METHOD, 0);

		User sessionUser = (User) request.getSession().getAttribute(Constants.SESSION_USER);
		RoleDao roleDao = DaoCreator.createRoleDao();
		ProblemDao problemDao = DaoCreator.createProblemDao();
		AccidentDao accidentDao = DaoCreator.createAccidentDao();
		Problem problem = problemDao.getProblemByID(problemID);
		Role role = roleDao.getRoleByUserID(sessionUser.getId());

		if (!roleDao.hasRight(Constants.AUTH_TYPE_ACCIDENT_FEEDBACK, sessionUser.getRoleID(), processMethod)) {
			request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_HAS_NOT_RIGHT_TO_PROCESS);
			return false;
		}

		if (!this.canbeProcessed(request, Constants.PROBLEM_TYPE_ACCIDENT_REGISTERFORM, sessionUser, problem)) {
			return false;
		}

		if (transferID == null) {
			this.createProblemTransfer(request, problemID);
		}

		boolean isSuccess = feedbackProblem(request);

		if (!isSuccess) {
			return false;
		}

		int[] currentTime = Util.getCurrentDate();

		String accidentName = request.getParameter(Constants.REQUEST_PARAMETER_ACCIDENT_NAME);
		String casualty = request.getParameter(Constants.REQUEST_PARAMETER_CASUALTY);
		String loss = request.getParameter(Constants.REQUEST_PARAMETER_LOSS);
		String overview = request.getParameter(Constants.REQUEST_PARAMETER_OVERVIEW);
		String reason = request.getParameter(Constants.REQUEST_PARAMETER_REASON);
		String moral = request.getParameter(Constants.REQUEST_PARAMETER_MORAL);
		String duty = request.getParameter(Constants.REQUEST_PARAMETER_DUTY);
		String team = request.getParameter(Constants.REQUEST_PARAMETER_TEAM);
		String introspection = request.getParameter(Constants.REQUEST_PARAMETER_INTROSPECTON);
		String reviewDetail = request.getParameter(Constants.REQUEST_PARAMETER_REVIEW_DETAIL);
		String reviewTeam = request.getParameter(Constants.REQUEST_PARAMETER_REVIEW_TEAM);
		String reviewTimeStr = request.getParameter(Constants.REQUEST_PARAMETER_REVIEW_TIME);
		String sendbackMsg = request.getParameter(Constants.REQUEST_PARAMETER_SENDBACK_MSG);

		Integer accidentTypeID = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_ACCIDENT_TYPE_ID, (Integer) null);
		Integer startYear = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_YEAR, currentTime[0]);
		Integer startMonth = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_MONTH, currentTime[1]);
		Integer startDay = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_DAY, currentTime[2]);
		Integer startHour = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_HOUR, currentTime[3]);
		Integer startMinute = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_MINUTE, currentTime[4]);

		if (!Util.isNullOrEmpty(accidentName)) {
			accidentName = Util.isoToUTF8(accidentName);
		}
		if (!Util.isNullOrEmpty(casualty)) {
			casualty = Util.isoToUTF8(casualty);
		}
		if (!Util.isNullOrEmpty(loss)) {
			loss = Util.isoToUTF8(loss);
		}
		if (!Util.isNullOrEmpty(overview)) {
			overview = Util.isoToUTF8(overview);
		}
		if (!Util.isNullOrEmpty(reason)) {
			reason = Util.isoToUTF8(reason);
		}
		if (!Util.isNullOrEmpty(moral)) {
			moral = Util.isoToUTF8(moral);
		}
		if (!Util.isNullOrEmpty(duty)) {
			duty = Util.isoToUTF8(duty);
		}
		if (!Util.isNullOrEmpty(team)) {
			team = Util.isoToUTF8(team);
		}
		if (!Util.isNullOrEmpty(introspection)) {
			introspection = Util.isoToUTF8(introspection);
		}
		if (!Util.isNullOrEmpty(reviewDetail)) {
			reviewDetail = Util.isoToUTF8(reviewDetail);
		}
		if (!Util.isNullOrEmpty(reviewTeam)) {
			reviewTeam = Util.isoToUTF8(reviewTeam);
		}
		if (!Util.isNullOrEmpty(sendbackMsg)) {
			sendbackMsg = Util.isoToUTF8(sendbackMsg);
		}

		Calendar accidentTime = Util.getCalendar(new int[] { startYear, startMonth, startDay, startHour, startMinute, 0 });
		Calendar reviewTime = null;
		try {
			reviewTime = Util.convertStrToDate(reviewTimeStr);
		} catch (Exception e) {
		}

		int accidentStatus = 0;
		if (processMethod == Constants.PROCESS_METHOD_CLOSE || processMethod == Constants.PROCESS_METHOD_PROVE) {
			accidentStatus = Constants.ACCIDENT_STATUS_COMPLETE;
		} else {
			accidentStatus = Constants.ACCIDENT_STATUS_UPDATE;
		}

		if (processMethod == Constants.PROCESS_METHOD_CLOSE || processMethod == Constants.PROCESS_METHOD_PROVE) {
			sendbackMsg = null;
		} else if (processMethod == Constants.PROCESS_METHOD_ESCALATE && problem.getEscalateDepart1ID() == null
				&& role.getRoleType() == Constants.ROLE_TYPE_BUZHANG) {
			sendbackMsg = null;
		} else if (processMethod != Constants.PROCESS_METHOD_SENDBACK) {
			sendbackMsg = accidentDao.getReportByID(problemID).getSendbackMsg();
		}

		problemDao.updateProblem(problemID, Constants.COLUMN_NAME_PROBLEM_TITLE, accidentName);
		isSuccess = accidentDao.updateAccidentReport(problemID, accidentTypeID, accidentTime, accidentStatus, overview, casualty, loss,
				reason, moral, duty, team, introspection, reviewDetail, reviewTeam, reviewTime, accidentName, sendbackMsg);
		isSuccess = accidentDao.updateAccidentCheckform(1, problemID, accidentTypeID, accidentTime, accidentStatus, overview, casualty,
				loss, reason, moral, duty, team, introspection, reviewDetail, reviewTeam, reviewTime, accidentName, sendbackMsg);

		if (!isSuccess) {
			request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_ACCIDENT_UPDATE_FAIL);
		}

		return isSuccess;
	}

	public boolean feedbackAccidentCheckform2(HttpServletRequest request) {
		Long transferID = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_TRANSFER_ID, (Long) null);
		Long problemID = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_ID, (Long) null);
		int processMethod = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_PROCESS_METHOD, 0);

		User sessionUser = (User) request.getSession().getAttribute(Constants.SESSION_USER);
		RoleDao roleDao = DaoCreator.createRoleDao();
		ProblemDao problemDao = DaoCreator.createProblemDao();
		AccidentDao accidentDao = DaoCreator.createAccidentDao();
		Problem problem = problemDao.getProblemByID(problemID);
		Role role = roleDao.getRoleByUserID(sessionUser.getId());

		if (!roleDao.hasRight(Constants.AUTH_TYPE_ACCIDENT_FEEDBACK, sessionUser.getRoleID(), processMethod)) {
			request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_HAS_NOT_RIGHT_TO_PROCESS);
			return false;
		}

		if (!this.canbeProcessed(request, Constants.PROBLEM_TYPE_ACCIDENT_REGISTERFORM, sessionUser, problem)) {
			return false;
		}

		if (transferID == null) {
			this.createProblemTransfer(request, problemID);
		}

		boolean isSuccess = feedbackProblem(request);
		if (!isSuccess) {
			return false;
		}

		int[] currentTime = Util.getCurrentDate();

		String accidentName = request.getParameter(Constants.REQUEST_PARAMETER_ACCIDENT_NAME);
		String casualty = request.getParameter(Constants.REQUEST_PARAMETER_CASUALTY);
		String loss = request.getParameter(Constants.REQUEST_PARAMETER_LOSS);
		String overview = null;
		String reason = request.getParameter(Constants.REQUEST_PARAMETER_REASON);
		String moral = request.getParameter(Constants.REQUEST_PARAMETER_MORAL);
		String duty = request.getParameter(Constants.REQUEST_PARAMETER_DUTY);
		String team = null;
		String introspection = request.getParameter(Constants.REQUEST_PARAMETER_INTROSPECTON);
		String reviewDetail = request.getParameter(Constants.REQUEST_PARAMETER_REVIEW_DETAIL);
		String reviewTeam = request.getParameter(Constants.REQUEST_PARAMETER_REVIEW_TEAM);
		String reviewTimeStr = request.getParameter(Constants.REQUEST_PARAMETER_REVIEW_TIME);
		String sendbackMsg = request.getParameter(Constants.REQUEST_PARAMETER_SENDBACK_MSG);

		Integer accidentTypeID = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_ACCIDENT_TYPE_ID, (Integer) null);
		Integer startYear = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_YEAR, currentTime[0]);
		Integer startMonth = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_MONTH, currentTime[1]);
		Integer startDay = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_DAY, currentTime[2]);
		Integer startHour = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_HOUR, currentTime[3]);
		Integer startMinute = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_MINUTE, currentTime[4]);

		if (!Util.isNullOrEmpty(accidentName)) {
			accidentName = Util.isoToUTF8(accidentName);
		}
		if (!Util.isNullOrEmpty(casualty)) {
			casualty = Util.isoToUTF8(casualty);
		}
		if (!Util.isNullOrEmpty(loss)) {
			loss = Util.isoToUTF8(loss);
		}
		if (!Util.isNullOrEmpty(reason)) {
			reason = Util.isoToUTF8(reason);
		}
		if (!Util.isNullOrEmpty(moral)) {
			moral = Util.isoToUTF8(moral);
		}
		if (!Util.isNullOrEmpty(duty)) {
			duty = Util.isoToUTF8(duty);
		}
		if (!Util.isNullOrEmpty(introspection)) {
			introspection = Util.isoToUTF8(introspection);
		}
		if (!Util.isNullOrEmpty(reviewDetail)) {
			reviewDetail = Util.isoToUTF8(reviewDetail);
		}
		if (!Util.isNullOrEmpty(reviewTeam)) {
			reviewTeam = Util.isoToUTF8(reviewTeam);
		}
		if (!Util.isNullOrEmpty(sendbackMsg)) {
			sendbackMsg = Util.isoToUTF8(sendbackMsg);
		}

		Calendar accidentTime = Util.getCalendar(new int[] { startYear, startMonth, startDay, startHour, startMinute, 0 });
		Calendar reviewTime = null;
		try {
			reviewTime = Util.convertStrToDate(reviewTimeStr);
		} catch (Exception e) {
		}

		int accidentStatus = 0;
		if (processMethod == Constants.PROCESS_METHOD_CLOSE || processMethod == Constants.PROCESS_METHOD_PROVE) {
			accidentStatus = Constants.ACCIDENT_STATUS_COMPLETE;
		} else {
			accidentStatus = Constants.ACCIDENT_STATUS_UPDATE;
		}

		if (processMethod == Constants.PROCESS_METHOD_CLOSE || processMethod == Constants.PROCESS_METHOD_PROVE) {
			sendbackMsg = null;
		} else if (processMethod == Constants.PROCESS_METHOD_ESCALATE && problem.getEscalateDepart1ID() == null
				&& role.getRoleType() == Constants.ROLE_TYPE_BUZHANG) {
			sendbackMsg = null;
		} else if (processMethod != Constants.PROCESS_METHOD_SENDBACK) {
			sendbackMsg = accidentDao.getCheckFormByID(2, problemID).getSendbackMsg();
		}
		problemDao.updateProblem(problemID, Constants.COLUMN_NAME_PROBLEM_TITLE, accidentName);
		isSuccess = accidentDao.updateAccidentCheckform(2, problemID, accidentTypeID, accidentTime, accidentStatus, overview, casualty,
				loss, reason, moral, duty, team, introspection, reviewDetail, reviewTeam, reviewTime, accidentName, sendbackMsg);

		if (!isSuccess) {
			request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_ACCIDENT_UPDATE_FAIL);
		}

		return isSuccess;
	}

	public boolean feedbackAccidentCheckform3(HttpServletRequest request) {
		Long transferID = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_TRANSFER_ID, (Long) null);
		Long problemID = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_ID, (Long) null);
		int processMethod = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_PROCESS_METHOD, 0);

		User sessionUser = (User) request.getSession().getAttribute(Constants.SESSION_USER);
		RoleDao roleDao = DaoCreator.createRoleDao();
		ProblemDao problemDao = DaoCreator.createProblemDao();
		AccidentDao accidentDao = DaoCreator.createAccidentDao();
		Problem problem = problemDao.getProblemByID(problemID);
		Role role = roleDao.getRoleByUserID(sessionUser.getId());

		if (!roleDao.hasRight(Constants.AUTH_TYPE_ACCIDENT_FEEDBACK, sessionUser.getRoleID(), processMethod)) {
			request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_HAS_NOT_RIGHT_TO_PROCESS);
			return false;
		}

		if (!this.canbeProcessed(request, Constants.PROBLEM_TYPE_ACCIDENT_REGISTERFORM, sessionUser, problem)) {
			return false;
		}

		if (transferID == null) {
			this.createProblemTransfer(request, problemID);
		}

		boolean isSuccess = feedbackProblem(request);
		if (!isSuccess) {
			return false;
		}

		int[] currentTime = Util.getCurrentDate();

		String accidentName = request.getParameter(Constants.REQUEST_PARAMETER_ACCIDENT_NAME);
		String casualty = request.getParameter(Constants.REQUEST_PARAMETER_CASUALTY);
		String loss = request.getParameter(Constants.REQUEST_PARAMETER_LOSS);
		String overview = null;
		String reason = request.getParameter(Constants.REQUEST_PARAMETER_REASON);
		String moral = request.getParameter(Constants.REQUEST_PARAMETER_MORAL);
		String duty = request.getParameter(Constants.REQUEST_PARAMETER_DUTY);
		String team = null;
		String introspection = request.getParameter(Constants.REQUEST_PARAMETER_INTROSPECTON);
		String reviewDetail = request.getParameter(Constants.REQUEST_PARAMETER_REVIEW_DETAIL);
		String reviewTeam = request.getParameter(Constants.REQUEST_PARAMETER_REVIEW_TEAM);
		String reviewTimeStr = request.getParameter(Constants.REQUEST_PARAMETER_REVIEW_TIME);
		String sendbackMsg = request.getParameter(Constants.REQUEST_PARAMETER_SENDBACK_MSG);

		Integer accidentTypeID = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_ACCIDENT_TYPE_ID, (Integer) null);
		Integer startYear = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_YEAR, currentTime[0]);
		Integer startMonth = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_MONTH, currentTime[1]);
		Integer startDay = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_DAY, currentTime[2]);
		Integer startHour = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_HOUR, currentTime[3]);
		Integer startMinute = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_START_MINUTE, currentTime[4]);

		if (!Util.isNullOrEmpty(accidentName)) {
			accidentName = Util.isoToUTF8(accidentName);
		}
		if (!Util.isNullOrEmpty(casualty)) {
			casualty = Util.isoToUTF8(casualty);
		}
		if (!Util.isNullOrEmpty(loss)) {
			loss = Util.isoToUTF8(loss);
		}
		if (!Util.isNullOrEmpty(reason)) {
			reason = Util.isoToUTF8(reason);
		}
		if (!Util.isNullOrEmpty(moral)) {
			moral = Util.isoToUTF8(moral);
		}
		if (!Util.isNullOrEmpty(duty)) {
			duty = Util.isoToUTF8(duty);
		}
		if (!Util.isNullOrEmpty(introspection)) {
			introspection = Util.isoToUTF8(introspection);
		}
		if (!Util.isNullOrEmpty(reviewDetail)) {
			reviewDetail = Util.isoToUTF8(reviewDetail);
		}
		if (!Util.isNullOrEmpty(reviewTeam)) {
			reviewTeam = Util.isoToUTF8(reviewTeam);
		}
		if (!Util.isNullOrEmpty(sendbackMsg)) {
			sendbackMsg = Util.isoToUTF8(sendbackMsg);
		}

		Calendar accidentTime = Util.getCalendar(new int[] { startYear, startMonth, startDay, startHour, startMinute, 0 });
		Calendar reviewTime = null;
		try {
			reviewTime = Util.convertStrToDate(reviewTimeStr);
		} catch (Exception e) {
		}

		int accidentStatus = 0;
		if (processMethod == Constants.PROCESS_METHOD_CLOSE || processMethod == Constants.PROCESS_METHOD_PROVE) {
			accidentStatus = Constants.ACCIDENT_STATUS_COMPLETE;
		} else {
			accidentStatus = Constants.ACCIDENT_STATUS_UPDATE;
		}

		if (processMethod == Constants.PROCESS_METHOD_CLOSE || processMethod == Constants.PROCESS_METHOD_PROVE) {
			sendbackMsg = null;
		} else if (processMethod == Constants.PROCESS_METHOD_ESCALATE && problem.getEscalateDepart1ID() == null
				&& role.getRoleType() == Constants.ROLE_TYPE_BUZHANG) {
			sendbackMsg = null;
		} else if (processMethod != Constants.PROCESS_METHOD_SENDBACK) {
			sendbackMsg = accidentDao.getCheckFormByID(3, problemID).getSendbackMsg();
		}

		problemDao.updateProblem(problemID, Constants.COLUMN_NAME_PROBLEM_TITLE, accidentName);
		isSuccess = accidentDao.updateAccidentCheckform(3, problemID, accidentTypeID, accidentTime, accidentStatus, overview, casualty,
				loss, reason, moral, duty, team, introspection, reviewDetail, reviewTeam, reviewTime, accidentName, sendbackMsg);

		if (!isSuccess) {
			request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_ACCIDENT_UPDATE_FAIL);
		}

		return isSuccess;
	}

	public boolean writeOther(HttpServletRequest request) {
		Long depart1ID = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_DEPARTMENT1ID, (Long) null);
		Long equipID = RequestUtil.getParameter(request, Constants.REQUEST_PARAMETER_EQUIP_ID, (Long) null);
		String defectTypeIDStr = request.getParameter(Constants.REQUEST_PARAMETER_DEFECT_TYPE_ID);
		String problemTitle = request.getParameter(Constants.REQUEST_PARAMETER_PROBLEM_TITLE);
		String problemContent = request.getParameter(Constants.REQUEST_PARAMETER_PROBLEM_CONTENT);
		String loss = request.getParameter(Constants.REQUEST_PARAMETER_LOSS);
		String reason = request.getParameter(Constants.REQUEST_PARAMETER_REASON);
		String zhenggaiCuoshi = request.getParameter(Constants.REQUEST_PARAMETER_ZHENGGAI_CUOSHI);
		String duty = request.getParameter(Constants.REQUEST_PARAMETER_DUTY);
		String team = request.getParameter(Constants.REQUEST_PARAMETER_TEAM);

		Integer defectTypeID = 0;
		Calendar writeDate = null;

		try {
			defectTypeID = new Integer(defectTypeIDStr);
		} catch (Exception e) {
		}

		if (!Util.isNullOrEmpty(problemTitle)) {
			problemTitle = Util.isoToUTF8(problemTitle);
		}

		if (!Util.isNullOrEmpty(problemContent)) {
			problemContent = Util.isoToUTF8(problemContent);
		}

		if (!Util.isNullOrEmpty(zhenggaiCuoshi)) {
			zhenggaiCuoshi = Util.isoToUTF8(zhenggaiCuoshi);
		}
		if (!Util.isNullOrEmpty(reason)) {
			reason = Util.isoToUTF8(reason);
		}

		if (!Util.isNullOrEmpty(loss)) {
			loss = Util.isoToUTF8(loss);
		}

		if (!Util.isNullOrEmpty(duty)) {
			duty = Util.isoToUTF8(duty);
		}

		if (!Util.isNullOrEmpty(team)) {
			team = Util.isoToUTF8(team);
		}

		User user = (User) request.getSession().getAttribute(Constants.SESSION_USER);

		ProblemDao problemDao = DaoCreator.createProblemDao();
		Problem problem = new Problem();
		problem.setProblemTitle(problemTitle);
		problem.setProblemContent(problemContent);
		problem.setProblemZhenggai(zhenggaiCuoshi);
		problem.setDepartment1ID(depart1ID);
		problem.setEquipmentID(equipID);

		problem.setProcessStatus(Constants.PROBLEM_STATUS_ZUZHANG_ZHUANGZHIZHANG);
		problem.setWriteTime(Calendar.getInstance());
		problem.setWriteUserID(user.getId());
		problem.setWriterDepartment1ID(user.getDepartment1ID());
		problem.setWriterDepartment2ID(user.getDepartment2ID());

		boolean isSuccess = problemDao.addProblem(problem);
		if (!isSuccess) {
			request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_CONVERT_FAIL);
			return false;
		}

		// Change problemID
		Long problemID = problem.getId();

		isSuccess = this.createProblemTransfer(request, problemID);
		if (!isSuccess) {
			request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_WRITE_FAIL);
			return false;
		}

		User sessionUser = (User) request.getSession().getAttribute(Constants.SESSION_USER);
		ProblemTransfer transfer = problemDao.getProblemTransfer(sessionUser.getId(), problemID, sessionUser.getId());
		isSuccess = this.feedbackProblem(request, String.valueOf(problemID), String.valueOf(transfer.getId()));
		if (!isSuccess) {
			problemDao.deleteProblemByIDList(new Long[] { problemID });
			// Feedback already set error information.
			return false;
		}

		isSuccess = problemDao.addOther(problemID, defectTypeID, writeDate, problemTitle, problemContent, loss, reason, zhenggaiCuoshi,
				duty, team, sessionUser.getId());
		if (!isSuccess) {
			request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_WRITE_FAIL);
			return false;
		}
		return isSuccess;
	}

	public boolean feedbackOther(HttpServletRequest request) {
		String processMethodStr = request.getParameter(Constants.REQUEST_PARAMETER_PROCESS_METHOD);
		String transferIDStr = request.getParameter(Constants.REQUEST_PARAMETER_TRANSFER_ID);
		String problemIDStr = request.getParameter(Constants.REQUEST_PARAMETER_ID);
		Long transferID = null;
		Long problemID = 0l;
		try {
			transferID = new Long(transferIDStr);
		} catch (Exception e) {
		}
		try {
			problemID = new Long(problemIDStr);
		} catch (Exception e) {
		}
		int processMethod = 0;
		try {
			processMethod = Integer.parseInt(processMethodStr);
		} catch (Exception e) {
		}

		User sessionUser = (User) request.getSession().getAttribute(Constants.SESSION_USER);
		RoleDao roleDao = DaoCreator.createRoleDao();
		ProblemDao problemDao = DaoCreator.createProblemDao();
		Problem problem = problemDao.getProblemByID(problemID);

		if (!roleDao.hasRight(Constants.AUTH_TYPE_DEFECT, sessionUser.getRoleID(), processMethod)) {
			request.setAttribute(Constants.REQUEST_ATTRIBUTE_ERROR, Constants.ERROR_KEY_HAS_NOT_RIGHT_TO_PROCESS);
			return false;
		}

		if (!this.canbeProcessed(request, Constants.PROBLEM_TYPE_DEFECT, sessionUser, problem)) {
			return false;
		}

		if (transferID == null) {
			this.createProblemTransfer(request, problemID);
		}

		boolean isSuccess = feedbackProblem(request);
		if (!isSuccess) {
			return false;
		}

		String problemTitle = request.getParameter(Constants.REQUEST_PARAMETER_PROBLEM_TITLE);
		String problemContent = request.getParameter(Constants.REQUEST_PARAMETER_PROBLEM_CONTENT);
		String loss = request.getParameter(Constants.REQUEST_PARAMETER_LOSS);
		String reason = request.getParameter(Constants.REQUEST_PARAMETER_REASON);
		String zhenggaiCuoshi = request.getParameter(Constants.REQUEST_PARAMETER_ZHENGGAI_CUOSHI);
		String duty = request.getParameter(Constants.REQUEST_PARAMETER_DUTY);
		String team = request.getParameter(Constants.REQUEST_PARAMETER_TEAM);

		if (!Util.isNullOrEmpty(problemTitle)) {
			problemTitle = Util.isoToUTF8(problemTitle);
		}

		if (!Util.isNullOrEmpty(problemContent)) {
			problemContent = Util.isoToUTF8(problemContent);
		}

		if (!Util.isNullOrEmpty(zhenggaiCuoshi)) {
			zhenggaiCuoshi = Util.isoToUTF8(zhenggaiCuoshi);
		}
		if (!Util.isNullOrEmpty(reason)) {
			reason = Util.isoToUTF8(reason);
		}

		if (!Util.isNullOrEmpty(loss)) {
			loss = Util.isoToUTF8(loss);
		}
		if (!Util.isNullOrEmpty(duty)) {
			duty = Util.isoToUTF8(duty);
		}
		if (!Util.isNullOrEmpty(team)) {
			team = Util.isoToUTF8(team);
		}

		boolean isSuccess2 = problemDao.updateOther(problemID, problemTitle, problemContent, loss, reason, zhenggaiCuoshi, duty, team);

		return isSuccess2;
	}
}
